Skip to content

Commit ace715c

Browse files
committed
capture exit code of callback and return at the end
because should set -e be disabled when withCustomOutputInput is called (which can happen for various reasons: on the left side of || in an if, function which uses withCustomOutputInput happens to be in an if etc. we would no longer exit.
1 parent 1a87e46 commit ace715c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/utility/io.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
# deleteDirChmod777 ".git"
4141
#
4242
###################################
43-
set -euo pipefail
43+
set -uo pipefail
4444
shopt -s inherit_errexit || { echo >&2 "please update to bash 5, see errors above" && exit 1; }
4545
unset CDPATH
4646

@@ -76,10 +76,12 @@ function withCustomOutputInput() {
7676
# same same if $withCustomOutputInput_fun should fail/exit, we don't setup a trap, the system should clean it up
7777
rm "$withCustomOutputInput_tmpFile" || true
7878

79-
$withCustomOutputInput_fun "$@"
79+
local exitCode=0
80+
$withCustomOutputInput_fun "$@" || exitCode=$?
8081

8182
eval "exec ${withCustomOutputInput_outputNr}>&-"
8283
eval "exec ${withCustomOutputInput_inputNr}<&-"
84+
return "$exitCode"
8385
}
8486

8587
function deleteDirChmod777() {

0 commit comments

Comments
 (0)