Skip to content

Instantly share code, notes, and snippets.

@benaryorg
Created June 6, 2015 20:12
Show Gist options
  • Save benaryorg/296386f05b12de599161 to your computer and use it in GitHub Desktop.
Save benaryorg/296386f05b12de599161 to your computer and use it in GitHub Desktop.
shell chaos
#!/bin/bash
set -E
trap '[ '$?' -ne 77 ] || exit 77' ERR
$(echo '$(exit 11)';exit 11)
(echo '(exit 11)';exit 11)
$(echo '$(exit 77)';exit 77)
(echo '(exit 77)';exit 77)
echo 'exit 0';exit 0
echo 'not to be printed'
$ ./test1.sh
./test1.sh: line 6: $(exit: command not found
(exit 11)
./test1.sh: line 10: $(exit: command not found
(exit 77)
exit 0
#!/bin/bash
set -E
trap '[ '$?' -ne 77 ] || exit 77' ERR
$(exit 11)
echo '$(exit 11)'
(exit 11)
echo '(exit 11)'
$(exit 77)
echo '$(exit 77)'
(exit 77)
echo '(exit 77)'
echo 'exit 0'
exit 0
echo 'not to be printed'
$ ./test2.sh
$(exit 11)
(exit 11)
$(exit 77)
(exit 77)
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment