Shell 命令 SET -X 在脚本中的意思 [英] Shell command SET -X mean in script

查看:50
本文介绍了Shell 命令 SET -X 在脚本中的意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个文件 deploy.sh,它有 shell 脚本.因为我知道它,所以我有点困惑,这就是 set -x 的实际含义.

So I have a file deploy.sh, and it has the shell script. Since I know about it, I have a little confusion, that is what does that set -x actually means.

运行文件后,我观察到文件中写在它之后的命令在终端中用 + 符号提及.

After running the file I have observed that the command written after it in the file gets mentioned in the terminal with a + sign.

就像我有这个一样,

#!/bin/bash
set -x

ng build

所以输出提到了 +ng build,当我从文件中注释 set -x 时,一切都会执行,但后面的命令没有出现在终端.

So the output mentions +ng build, and when I comment the set -x from the file, everything executes, but the later commands does not show up in the terminal.

我已经研究过它,但特别找不到这个特定命令的真正含义和工作.

I have researched about it, but specifically couldn't find the real meaning and work of this particular command.

推荐答案

您可以阅读 bash 在线手册:

You can read the bash online manual for set:

-x

打印简单命令的痕迹,对于命令,大小写命令,选择命令,以及命令及其参数的算术或展开之后和展开之前的关联单词列表执行.PS4 变量的值被扩展,结果值打印在命令及其扩展参数之前.

Print a trace of simple commands, for commands, case commands, select commands, and arithmetic for commands and their arguments or associated word lists after they are expanded and before they are executed. The value of the PS4 variable is expanded and the resultant value is printed before the command and its expanded arguments.

所以它完全符合你的描述.

So it does exactly what you described.

这篇关于Shell 命令 SET -X 在脚本中的意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆