From the description of set in the bash man page:
-v Print shell input lines as they are read.
Thus, the following example script:
#!/usr/bin/env bash
# setv.sh
set -v
foo=bar
echo $foo
Generates output:
foo=bar
echo $foo
bar
Is there a way for it to prepend some string, say "+ " to each line, so as to clearly indicate which line is a line from the script, and which line is output of a line of from the script. Using the above example, the desired output would be:
+ foo=bar
+ echo $foo
bar