I cracked the solution for this recently when I pissed it off:
shopt -s expand_aliases _xtrace() { case $1 in on) set -x ;; off) set +x ;; esac } alias xtrace='{ _xtrace $(cat); } 2>/dev/null <<<'
This allows you to enable and disable xtrace, as in the following, where I register how arguments are assigned to variables:
xtrace on ARG1=$1 ARG2=$2 xtrace off
And you get an output that looks like this:
$ ./script.sh one two + ARG1=one + ARG2=two
user108471 Jul 01 '14 at 18:32 2014-07-01 18:32
source share