paperlined.org
rosetta_stone > languages
document updated 11 years ago, on Mar 29, 2013
Ways to get a scripting language to echo the line being executed before it actually runs it.

older BASIC

TRON

(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

KSH

set -o xtrace or set -x


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

Bash

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.

Perl

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

and several other ways

Make

make SHELL='bash -x'

Better yet, use GNU Remake.