Skip to content

Instantly share code, notes, and snippets.

@Romero027
Created October 3, 2020 19:00
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 Romero027/81770c8562b1ad1cd9343ebba65bfe1e to your computer and use it in GitHub Desktop.
Save Romero027/81770c8562b1ad1cd9343ebba65bfe1e to your computer and use it in GitHub Desktop.
Use DEBUG Trap to step through a bash script line by line - by Julia Evans
#!/bin/bash
# See https://jichu4n.com/posts/debug-trap-and-prompt_command-in-bash/ for a in-depth discussion
trap '(read -p "[$BASH_SOURCE:$LINENO] $BASH_COMMAND?")' DEBUG
var=2
echo $((var+2))
for i in 1 2 3 4 5
do
echo "Welcome $i times"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment