gpt4 book ai didi

bash - fish shell : how to exit on error (bash set -e)

转载 作者:行者123 更新时间:2023-11-29 08:53:04 25 4
gpt4 key购买 nike

在 bash 上,您可以在脚本中使用 set -e 以便在出错时退出:

set -e
cd unexisting-folder
echo "this line will not be printed"

但在 fish shell 上 set -e 用于删除变量:

set FOO bar
set -e FOO
echo {$FOO} # prints newline

Bash set -e 在 Fish 上的等效项是什么?

最佳答案

fish 中没有类似的东西。 https://github.com/fish-shell/fish-shell/issues/805花一点时间讨论这个可疑的版本可能是什么样子。

如果脚本很短,在每一行前加上前缀可能不会太糟糕:

cp file1 file2
and rm file1
and echo File moved

关于bash - fish shell : how to exit on error (bash set -e),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19876032/

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