diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2012-12-13 22:38:51 +0100 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2012-12-13 23:15:19 +0100 |
commit | 0dc57566bc5a25d2b086de333844a3c00addf0e4 (patch) | |
tree | b191d9a5f00833e3a892e0f6a0243f3ab2d3ff82 | |
parent | a6480f105fc2e2cff73ccc9953792e7af68743b7 (diff) | |
download | ptxdist-0dc57566bc5a25d2b086de333844a3c00addf0e4.tar.gz ptxdist-0dc57566bc5a25d2b086de333844a3c00addf0e4.tar.xz |
ptxdist: cleanup output redirection
5, 6 and 7 are also used in configure scripts, so avoid those.
Allocate PTXDIST_FD_STDOUT and PTXDIST_FD_STDERR dynamically
Set PTXDIST_FD_LOGFILE=9 so the wrapper works when 'dash' is /bin/sh for
the wrapper scripts: dash only works with 0-9 for fd redirection.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r-- | scripts/libptxdist.sh | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/scripts/libptxdist.sh b/scripts/libptxdist.sh index 0f1f7435e..86074fa06 100644 --- a/scripts/libptxdist.sh +++ b/scripts/libptxdist.sh @@ -362,33 +362,29 @@ ptxd_make() { # # supress stdout in quiet mode # -ptxd_make_log() { - # - # fd3 == stdout to logfile - # fd4 == stderr to logfile - # fd5 == clean stdout - # fd6 == clean stderr - # - { - export PTXDIST_FD_STDOUT=5 - export PTXDIST_FD_STDERR=6 - export PTXDIST_FD_LOGFILE=7 - { - if [ -z "${PTXDIST_QUIET}" ]; then - ptxd_make "${@}" 4>&- | - # make's stdout on fd0 - tee -a "${PTX_LOGFILE}" 2>&4 4>&- 5>&- 6>&- - check_pipe_status || return - else - exec 4>&- - ptxd_make "${@}" 1>> "${PTX_LOGFILE}" - fi - } 2>&1 1>&3 3>&- 7>> "${PTX_LOGFILE}" | - # make's stderr on fd0 - tee -a "${PTX_LOGFILE}" 1>&2 3>&- 4>&- 5>&- 6>&- - check_pipe_status || return - } 3>&1 4>&2 5>&1 6>&2 -} +ptxd_make_log() {( + # stdout only + exec {PTXDIST_FD_STDOUT}>&1 + # stderr only + exec {PTXDIST_FD_STDERR}>&2 + # logfile only + exec 9>> "${PTX_LOGFILE}" + export PTXDIST_FD_STDOUT + export PTXDIST_FD_STDERR + export PTXDIST_FD_LOGFILE=9 + + if [ -z "${PTXDIST_QUIET}" ]; then + # stdout and logfile + exec {logout}> >(tee -a "${PTX_LOGFILE}") + else + # logfile only + exec {logout}>> "${PTX_LOGFILE}" + fi + # stderr and logfile + exec {logerr}> >(tee -a "${PTX_LOGFILE}" >&2) + + ptxd_make "${@}" 1>&${logout} 2>&${logerr} +)} |