bash - '#!/bin/sh -xe' 是什么意思?

标签 bash sh

这个问题在这里已经有了答案:





What does the line '!/bin/sh -e' do? [closed]

(2 个回答)



How to echo shell commands as they are executed

(14 个回答)


2年前关闭。




Tribler 的 GitHub 上的存储库中,我看到一个file与口译员:#!/bin/sh -xe .

在 Mac 和 Linux 上 man sh重定向到 BASH(1) (与 man bash 相同)。

在这个 man 文件中,在以下部分:

OPTIONS



, 没有提到选项 -x ,也不是选项 -e .

解释器是什么意思#!/bin/sh -xe ?

最佳答案

我找到了这个:
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.

似乎这些只是错误控制选项,可确保在命令失败时不会发生更糟糕的事情。

关于bash - '#!/bin/sh -xe' 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53574827/

相关文章:

python - 使用 pyudev 设置键盘布局

json - 使用 awk 从较大的 JSON 字符串中提取标记

bash - 将变量子目录分配给 shell 脚本中的输出命令

bash - 如何指定 Bourne shell(不是 sh)

linux - Oracle数据库警报日志脚本错误

bash - tail -f、awk 并输出到文件 >

bash - USB 供应商和产品 ID 到设备绑定(bind)

java - kdb q - 尽管设置了 $QHOME,但仍未找到许可证

linux - ssh 端口转发 ("ssh -fNL") 无法通过 expect spawn 自动提供密码

python - 为什么这个带有 shebang #!/bin/sh 和 4 个单引号内的 exec python 的片段有效?