Last active
August 29, 2015 14:26
-
-
Save jimjh/6904faaf7d99ea5662e9 to your computer and use it in GitHub Desktop.
script template
This file contains 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
#!/usr/bin/env bash | |
# Usage: | |
# Without trace, just run `./do-stuff.sh` | |
# With trace, use `BASH_XTRACEFD=3 ./do-stuff 3> trace.txt` | |
# Requires bash 4.+ | |
set -o pipefail | |
set -o nounset | |
set -o errexit | |
if [[ ${BASH_XTRACEFD:+x} ]]; then | |
set -o xtrace | |
fi | |
if false; then | |
cat /tmp/w00t > /dev/null | |
else | |
cat /tmp/w11t > /dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If
BASH_XTRACEFD
is set, turns onxtrace
and outputs trace to the given file descriptor. Otherwise, does not usextrace
.