Skip to content

Instantly share code, notes, and snippets.

View major0's full-sized avatar
🏠
Working from home

Mark Ferrell major0

🏠
Working from home
View GitHub Profile
@major0
major0 / gist:159c0e25d0d24fced074
Created May 16, 2014 21:16
Bash fails to call exit_handler() if an error happens in the function called within a subshell.
set -e
exit_handler() { echo "exit code: $?"; }
false() { !:; }
main()
{(
trap exit_handler 0
"$@" >> /dev/null 2>&1
)}
main "$@"