summaryrefslogtreecommitdiffstats
path: root/src/usr/local/sbin
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2015-10-23 15:50:53 -0200
committerRenato Botelho <renato@netgate.com>2015-10-23 15:50:53 -0200
commit463c438d4765c72b9d9a00ab4b90160c29ac1d64 (patch)
treec3806f18e2d263424c47295c9585ee65aabc8287 /src/usr/local/sbin
parentb194ed9ea6876e48bce10e8d63ef61f86affcd89 (diff)
downloadpfsense-463c438d4765c72b9d9a00ab4b90160c29ac1d64.zip
pfsense-463c438d4765c72b9d9a00ab4b90160c29ac1d64.tar.gz
Make it possible to _exec to get $_cmd exit code instead of tee one
Diffstat (limited to 'src/usr/local/sbin')
-rwxr-xr-xsrc/usr/local/sbin/pfSense-upgrade13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/usr/local/sbin/pfSense-upgrade b/src/usr/local/sbin/pfSense-upgrade
index 6b16e2a..e14348e 100755
--- a/src/usr/local/sbin/pfSense-upgrade
+++ b/src/usr/local/sbin/pfSense-upgrade
@@ -96,11 +96,18 @@ _exec() {
_echo -n ">>> ${_msg}... "
if [ -z "${_stdout}" ]; then
_echo ""
- ${_cmd} 2>&1 | tee -a ${logfile}
+ # Ref. http://stackoverflow.com/questions/1221833/bash-pipe-output-and-capture-exit-status
+ exec 4>&1
+ local _result=$({ { ${_cmd} 2>&1 3>&-; printf $? 1>&3; } 4>&- | \
+ tee -a ${logfile} 1>&4; } 3>&1)
+ exec 4>&-
else
- ${_cmd} >${_stdout} 2>&1 | tee -a ${logfile}
+ # Ref. http://stackoverflow.com/questions/1221833/bash-pipe-output-and-capture-exit-status
+ exec 4>&1
+ local _result=$({ { ${_cmd} >${_stdout} 2>&1 3>&-; printf $? 1>&3; } 4>&- | \
+ tee -a ${logfile} 1>&4; } 3>&1)
+ exec 4>&-
fi
- local _result=$?
if [ ${_result} -eq 0 -o -n "${_ignore_result}" ]; then
[ -n "${_stdout}" ] \
OpenPOWER on IntegriCloud