dont-try-to-OR-after-source
If you have the following example code:
set -e
failingFunc() {
echo "failingFunc will return 1"
return 1
}
failing-main_MAIN() {
echo "PrintA, will 'return 1', on next line."
failingFunc
echo "PrintB, will should NOT be printed. (after 'return 1')"
}
failing-main_MAIN
You expect set -e
to guarantee an exit (Refer to For now Avoid 'set -e' Flag in Scripts) when function returns non 0 return code. Not reaching 'PrintB'. However, if you were to source the file and use '||' operator after the sourcing.
Such as:
source ./failing-main.sh || echo "Added || after failing main."
You would in fact see the following output:
PrintA, will 'return 1', on next line.
failingFunc will return 1
PrintB, will should NOT be printed. (after 'return 1')
Working example
gt.sandbox.checkout.commit.cleanly 7c3b984 \
&& cd shell/bash \
&& source ./failing-main.sh || echo "Added || after failing main."
Instead
??