I found this:
man sh
:
-x xtrace Write each command to standard error (preceded by
a ‘+ ’) before it is executed. Useful for debug‐
ging.
-e errexit If not interactive, exit immediately if any
untested command fails. The exit status of a com‐
mand is considered to be explicitly tested if the
command is used to control an if, elif, while, or
until; or if the command is the left hand operand
of an “&&” or “||” operator.
看起来这些只是错误控制选项,如果一个命令失败了,它们确保不会发生更糟糕的情况。
-e
可能会非常适得其反,会在本来没有错误的情况下产生错误。请参阅BashFAQ#105中的练习以及不同shell如何处理此标志的不兼容性列表,网址为https://www.in-ulm.de/~mascheck/various/set-e/。 - Charles Duffy按照man手册: 阅读更多
-a,-b,-C,-e,-f,-m,-n,-o选项,-u,-v和-x选项被描述为特殊内置实用程序中的一部分。从set特殊内置派生的选项字母也可以接受一个前导加号('+')而不是一个前导连字符(表示本卷IEEE Std 1003.1-2001中所述选项的反向情况)。
当您阅读set
man页面时,您会得到:
-x shell在扩展命令并在执行命令之前将跟踪写入标准错误。未指定是否跟踪关闭跟踪的命令。
以及
-e 当此选项打开时,如果一个简单的命令因Shell错误或返回一个大于0的退出状态值而失败,并且不是while、until或if关键字后面的复合列表的一部分,也不是AND或OR列表的一部分,并且不是由!保留字前导的管道,则Shell将立即退出。
-e
,可以参考这个答案。 - alegriaOPTIONS
部分的第一行说明了在启动bash
时,您可以使用所有在set
内置文档中记录的选项(包括-x
和-e
)。接下来的标志只是额外的标志。 - chepner