首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Bash命令选项澄清bash -ex

Bash命令选项澄清bash -ex
EN

Stack Overflow用户
提问于 2022-02-08 09:15:07
回答 1查看 83关注 0票数 0

请你向我解释一下这个shell命令到底是做什么的?很难检索这个-ex选项的描述。

sh #!/bin/bash -ex

提前感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-08 09:39:33

这意味着您正在使用-e和-x shell选项调用新的bash

请参见此处的shell选项:https://tldp.org/LDP/abs/html/options.html

-e errexit Abort script at first error, when a command exits with non-zero status (except in until or while loops, if-tests, list constructs)

-x xtrace Similar to -v, but expands commands

因为-x类似于-v:

-v verbose Print each command to stdout before executing it

所以它实际上是下降到下一层的外壳:

代码语言:javascript
运行
复制
$ echo $SHLVL
1
$ sh #!/bin/bash -ex
$ echo $SHLVL
2

在这个级别2的shell中,选项-e和-x被激活。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71031262

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档