Check set -x in dash
This works in dash, and bash in sh-compliant mode.
is_x_set="$( set -o | awk '/xtrace/{if($2=="on")print "Y"}' )" sh ${is_x_set:+-x }/path/to/subscript.sh
This example here shows how to run a subscript with "set -x" if the parent script was called with that, or if it is currently set at this point in the parent script.
Comments