Better "exec 3>&1" comment
"Copy stdout to fd 3" is confusing. Explain the intention behind `exec 3>&1`.
Change-Id: Id19434121876e65a14c709beac26b9daf4a36a0a
diff --git a/stack.sh b/stack.sh
index 4a8cb90..19d47d6 100755
--- a/stack.sh
+++ b/stack.sh
@@ -543,10 +543,11 @@
# 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
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} '
/((set \+o$)|xtrace)/ { next }
{
@@ -559,7 +560,7 @@
print
fflush("")
}' ) 2>&1
- # Set up a second fd for output
+ # Set fd 6 to summary log file
exec 6> >( tee "${SUMFILE}" )
else
# Set fd 1 and 2 to primary logfile
@@ -574,7 +575,8 @@
ln -sf $SUMFILE $LOGDIR/$LOGFILENAME.summary
else
# 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
if [[ "$VERBOSE" != "True" ]]; then
# Throw away stdout and stderr