Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Thank you, that makes sense. Is there a way to capture the exit 3 outside of a subshell? I want both the STDOUT and the RETVAL. I guess with $?. Commented Dec 7, 2016 at 21:38
  • See expanded answer. Commented Dec 7, 2016 at 21:42
  • Thank you. The set -e I had was causing it to exit prematurely in the example you gave, but I understand how it's behaving now. For anyone else who ends up here, this link has some good examples of subshells and return statuses: mywiki.wooledge.org/BashFAQ/002 Commented Dec 7, 2016 at 21:56
  • set -e will terminate a script if anything returns a nonzero exit code that isn't immediately caught with an if or other conditional statement. Commented Dec 7, 2016 at 22:04