在 bash 中,当使用该-x
选项运行时,是否可以免除单个命令的回显?
我试图使输出尽可能整洁,所以我在带有set +x
. 但是,行set +x
本身仍然被回显,并且不会向输出添加任何有价值的信息。
我记得在过去糟糕的.bat
日子里,当运行时echo on
,个别行可以通过以@
. bash 中是否有任何等价物?
#!/bin/bash -x
function i_know_what_this_does() {
(
set +x
echo do stuff
)
}
echo the next-next line still echoes 'set +x', is that avoidable?
i_know_what_this_does
echo and we are back and echoing is back on
Run Code Online (Sandbox Code Playgroud)
运行上述程序时,输出为:
+ echo the next-next line still echoes 'set +x,' is that 'avoidable?'
the next-next line still echoes set +x, is that …
Run Code Online (Sandbox Code Playgroud)