3 ms·
What this really boils down to is you should avoid subshells where possible and handle this with either variable assignment or and streams (pipes). eg: set -
by RijilV 9y ago
What this really boils down to is you should avoid subshells where possible and handle this with either variable assignment or and streams (pipes).
eg:
set -euo pipefail
foo() {
false
echo "hello world"
}
variable=$(foo) # fails
foo | do_stuff # fails
My preference is to handle things as streams