8135014: logger.sh needs to handle commands with variable assignment prefixes

Reviewed-by: erikj
This commit is contained in:
Magnus Ihse Bursie 2015-09-03 15:01:57 +02:00
parent 6047d89d1b
commit 9098325d7a

View File

@ -41,5 +41,19 @@ RCDIR=`mktemp -dt jdk-build-logger.tmp.XXXXXX` || exit $?
trap "rm -rf \"$RCDIR\"" EXIT
LOGFILE=$1
shift
# We need to handle command likes like "VAR1=val1 /usr/bin/cmd VAR2=val2".
# Do this by shifting away prepended variable assignments, and export them
# instead.
is_prefix=true
for opt; do
if [[ "$is_prefix" = true && "$opt" =~ ^.*=.*$ ]]; then
export $opt
shift
else
is_prefix=false
fi
done
(exec 3>&1 ; ("$@" 2>&1 1>&3; echo $? > "$RCDIR/rc") | tee -a $LOGFILE 1>&2 ; exec 3>&-) | tee -a $LOGFILE
exit `cat "$RCDIR/rc"`