`set -x` 有什么作用? [英] What does `set -x` do?
本文介绍了`set -x` 有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含以下行的 shell 脚本:
I have a shell script with the following line in it:
[ "$DEBUG" == 'true' ] && set -x
推荐答案
set -x
启用 shell 模式,其中所有执行的命令都打印到终端.在您的情况下,它显然用于调试,这是 set -x
的典型用例:在执行时打印每个命令可能会帮助您可视化脚本的控制流(如果脚本不起作用)正如预期的那样.
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
禁用它.
这篇关于`set -x` 有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文