Better "exec 3>&1" comment

"Copy stdout to fd 3" is confusing. Explain the intention behind `exec 3>&1`.

Change-Id: Id19434121876e65a14c709beac26b9daf4a36a0a
This commit is contained in:
Jun Wu 2014-04-28 20:36:08 +08:00
parent 376a4a1a40
commit 8710b6501b

View File

@ -543,10 +543,11 @@ if [[ -n "$LOGFILE" ]]; then
# Redirect output according to config # Redirect output according to config
# Copy stdout to fd 3 # Set fd 3 to a copy of stdout. So we can set fd 1 without losing
# stdout later.
exec 3>&1 exec 3>&1
if [[ "$VERBOSE" == "True" ]]; then if [[ "$VERBOSE" == "True" ]]; then
# Redirect stdout/stderr to tee to write the log file # Set fd 1 and 2 to write the log file
exec 1> >( awk -v logfile=${LOGFILE} ' exec 1> >( awk -v logfile=${LOGFILE} '
/((set \+o$)|xtrace)/ { next } /((set \+o$)|xtrace)/ { next }
{ {
@ -559,7 +560,7 @@ if [[ -n "$LOGFILE" ]]; then
print print
fflush("") fflush("")
}' ) 2>&1 }' ) 2>&1
# Set up a second fd for output # Set fd 6 to summary log file
exec 6> >( tee "${SUMFILE}" ) exec 6> >( tee "${SUMFILE}" )
else else
# Set fd 1 and 2 to primary logfile # Set fd 1 and 2 to primary logfile
@ -574,7 +575,8 @@ if [[ -n "$LOGFILE" ]]; then
ln -sf $SUMFILE $LOGDIR/$LOGFILENAME.summary ln -sf $SUMFILE $LOGDIR/$LOGFILENAME.summary
else else
# Set up output redirection without log files # Set up output redirection without log files
# Copy stdout to fd 3 # Set fd 3 to a copy of stdout. So we can set fd 1 without losing
# stdout later.
exec 3>&1 exec 3>&1
if [[ "$VERBOSE" != "True" ]]; then if [[ "$VERBOSE" != "True" ]]; then
# Throw away stdout and stderr # Throw away stdout and stderr