Skip to content

Instantly share code, notes, and snippets.

@BanzaiMan
Last active August 5, 2016 14:30
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 BanzaiMan/214404ba31d334b1b9af11c690c05eef to your computer and use it in GitHub Desktop.
Save BanzaiMan/214404ba31d334b1b9af11c690c05eef to your computer and use it in GitHub Desktop.
Test "set -e" behavior inside a function in Bash
#!/bin/bash
# set -x
function test_function
{
set -e
echo "opts in test_function: $-"
false
echo pass through
return 0
}
echo "opts before: $-"
if ! eval test_function; then
echo test_function failed
else
echo test_function passed
fi
echo "opts after: $-"
false
echo end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment