Ways to get a scripting language to echo the line being executed before it actually runs it.

older BASIC


(it's rumored that this was the origin of the name of the movie "Tron", but unfortunately, this was not the case)

DOS batch files

echo on


set -o xtrace or set -x

PS4='line $LINENO: ' ksh -x scriptname


export PS4='$BASH_SOURCE:$LINENO>> '
set -x
To make it selectively activatable, and work across child process boundaries, put this at the top of all your Bash scripts:
if [ "$BASH_TRON" != "" ]; then export PS4="\033[104;30m$BASH_SOURCE:$LINENO>>\033[0m "; set -x; fi
The Bash Debugger project is also available if you need to go further.


PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2"

and several other ways


make SHELL='bash -x'

Better yet, use GNU Remake.