Last active
August 5, 2016 14:30
-
-
Save BanzaiMan/214404ba31d334b1b9af11c690c05eef to your computer and use it in GitHub Desktop.
Test "set -e" behavior inside a function in Bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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