Skip to content

Instantly share code, notes, and snippets.

@obatiuk
Last active May 26, 2018 07:50
Show Gist options
  • Save obatiuk/54504c28d365b1766467ca00ad446af0 to your computer and use it in GitHub Desktop.
Save obatiuk/54504c28d365b1766467ca00ad446af0 to your computer and use it in GitHub Desktop.
Simple line to enable debug in shell if '-debug' argument is specified
# version #1: enables xtrace if `--debug` argument is supplied
[ -n "$(echo $@ | grep "\--debug")" ] && set -x
# version #2: sets debug variable to 'true' if `--debug` argument is supplied or `xtrace` option is set
debug=false && [ -n "$(echo $@ | grep "\--debug")" ] || [ -n "$(set | grep xtrace)" ] && debug=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment