我一直在 bash 脚本中使用“set -x”来帮助我调试一些功能,它对我来说效果很好
-x After expanding each simple command, for command, case command,
select command, or arithmetic for command, display the expanded
value of PS4, followed by the command and its expanded arguments or
associated word list.
但是,我希望能够在离开该功能之前将其清除
例如:
#/bin bash
function somefunction()
{
set -x
# some code I'm debugging
# clear the set -x
set ????
}
somefunction