What does `set -x` do?

前端 未结 3 2049
温柔的废话
温柔的废话 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:07

    set -x enables a mode of the shell where all executed commands are printed to the terminal. In your case it's clearly used for debugging, which is a typical use case for set -x: printing every command as it is executed may help you to visualize the control flow of the script if it is not functioning as expected.

    set +x disables it.

提交回复
热议问题