我一直在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.
Run Code Online (Sandbox Code Playgroud)
但是我想在离开这个功能之前能够清除它
例如:
#/bin bash
function somefunction()
{
set -x
# some code I'm debugging
# clear the set -x
set ????
}
somefunction
Run Code Online (Sandbox Code Playgroud)