What does `set -x` do?

前端 未结 3 2050
温柔的废话
温柔的废话 2020-11-29 16:26

I have a shell script with the following line in it:

[ \"$DEBUG\" == \'true\' ] && set -x
3条回答
  •  佛祖请我去吃肉
    2020-11-29 17:16

    -u: disabled by default. When activated, an error message is displayed when using an unconfigured variable.

    -v: inactive by default. After activation, the original content of the information will be displayed (without variable resolution) before the information is output.

    -x: inactive by default. If activated, the command content will be displayed before the command is run (after variable resolution, there is a ++ symbol).

    Compare the following differences:

    / # set -v && echo $HOME
    /root
    / # set +v && echo $HOME
    set +v && echo $HOME
    /root
    
    / # set -x && echo $HOME
    + echo /root
    /root
    / # set +x && echo $HOME
    + set +x
    /root
    
    / # set -u && echo $NOSET
    /bin/sh: NOSET: parameter not set
    / # set +u && echo $NOSET
    

提交回复
热议问题