5 ms·
I don't think you can capture/handle exit codes of subshells anyway, right? I've been operating under that assumption for years, and just don't do subshells if
by ryapric 4y ago
I don't think you can capture/handle exit codes of subshells anyway, right? I've been operating under that assumption for years, and just don't do subshells if I can avoid them.
- 0xbadcafebee 4y ago$? contains the return status for subshells, commands, pipelines, functions, etc. From the man page, under Special Parameters : ? Expands to the exit status of the most recently executed foreground pipeline. $ foo="$(echo foobar ; exit 3)" ; ret=$? ; echo "output: $foo" ; echo "return status: $ret" output: foobar return status: 3 Also, PIPESTATUS is an array with the return status from each command in a pipeline.