Skip to content

Instantly share code, notes, and snippets.

@wwalker
Created October 1, 2020 16:59
Show Gist options
  • Save wwalker/95163c9fdfc624526ba32b8e38584534 to your computer and use it in GitHub Desktop.
Save wwalker/95163c9fdfc624526ba32b8e38584534 to your computer and use it in GitHub Desktop.
# debug-script a script/run script while gathering debug info
ds(){
local cmd
local PS4
local basename
basename=${1%%*/}
cmd=$(command -v "$1")
shift
PS4='+ ($?) ($LINENO) '
PS4="$PS4" bash -x "$cmd" "$@" |& tee ~/logs/"$basename-$(date +%FT%T)" | grep -v "^${PS4:0:1}"
}
# debug-it used to debug a function
di(){
set -x
"$@"
set +x
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment