Skip to content

Instantly share code, notes, and snippets.

@terrorobe
Created September 22, 2016 20:07
Show Gist options
  • Save terrorobe/d19fa5ef946513d25921cd9b1c36a72b to your computer and use it in GitHub Desktop.
Save terrorobe/d19fa5ef946513d25921cd9b1c36a72b to your computer and use it in GitHub Desktop.
robe@abundantia ~/tmp % cat exit_2.sh
#!/bin/sh
exit 2
robe@abundantia ~/tmp % cat subshell_one_command.sh
#!/bin/bash
set -e
(
./exit_2.sh
)
robe@abundantia ~/tmp % cat subshell_two_commands.sh
#!/bin/bash
set -e
(
echo "starting!"
./exit_2.sh
)
robe@abundantia ~/tmp % ./subshell_one_command.sh
2 robe@abundantia ~/tmp % echo $?
2
robe@abundantia ~/tmp % ./subshell_two_commands.sh
starting!
1 robe@abundantia ~/tmp % echo $?
1
robe@abundantia ~/tmp %
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment