清除脚本中的'-x选项'

Adr*_*ian 1 linux bash

我一直在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)

har*_*pun 5

引用手册:

使用+而不是 - 导致这些标志被关闭.

所以这set +x就是你要找的东西.