gpt4 book ai didi

bash:使用 set -e 运行脚本(errexit)

转载 作者:行者123 更新时间:2023-11-29 09:03:45 24 4
gpt4 key购买 nike

有没有一种方法可以使用 set -e 运行 bash 脚本,也就是说,就好像 set -e 位于脚本的第一行?我知道有例如 bash -x 来模拟 set -x,但我没有看到任何可以模拟 set -e 的东西。

最佳答案

bash 可以使用任何对 set 有效的选项作为命令行选项,所以你可以简单地使用

bash -e myScript

这是手册页选项部分的第一句话(强调我的;我知道我也忽略了这句话很长时间):

In addition to the single-character shell options documented in the description of the set builtin command, bash interprets the following options when it is invoked:

关于bash:使用 set -e 运行脚本(errexit),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17076342/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com