Skip to content

Instantly share code, notes, and snippets.

@rcrowley
Created March 31, 2016 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcrowley/724970de828cb445e14e958efa5ac2f0 to your computer and use it in GitHub Desktop.
Save rcrowley/724970de828cb445e14e958efa5ac2f0 to your computer and use it in GitHub Desktop.
This is very important if you write shell programs
█ $ cat false-trap-true.sh
set -e -x
trap false EXIT
true
█ $ cat true-trap-false.sh
set -e -x
trap true EXIT
false
█ $ sh false-trap-true.sh; echo $?
+ trap false EXIT
+ true
+ false
1
█ $ sh true-trap-false.sh; echo $?
+ trap true EXIT
+ false
+ true
1
█ $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment