I have a little function that I put in scripts that need to do that:
Code:
function run() { # Display a command and run it
echo "${PS4}$*" >&2
PS4="+$PS4" "$@"
}
Commands for which I want to see that output are executed with
Code:
run some_command [options] arg_1 arg_2 ...
The output mimics the way the "-x" in
bash displays nested commands, with the output going to stderr.