To help with debugging a script, you can use the "echo before execute" setting:
Turn on "echo before execute":
set -x
Turn off "echo before execute":
set +x
Turn off "echo before execute" without printing the line:
{ set +x; } 2>/dev/null
Example to turn on, then run some commands, then turn off:
set -x
command1
command2
command3
{ set +x; } 2>/dev/null