在 bash 上,您可以set -e在脚本中使用以在出错时退出:
set -e
cd unexisting-folder
echo "this line will not be printed"
但是在fish shellset -e上是用来擦除变量的:
set FOO bar
set -e FOO
echo {$FOO} # prints newline
什么是 Bash set -eon Fish 的等价物?
在 bash 上,您可以set -e在脚本中使用以在出错时退出:
set -e
cd unexisting-folder
echo "this line will not be printed"
但是在fish shellset -e上是用来擦除变量的:
set FOO bar
set -e FOO
echo {$FOO} # prints newline
什么是 Bash set -eon Fish 的等价物?
鱼中没有类似的东西。https://github.com/fish-shell/fish-shell/issues/805花一点时间讨论这个可疑的版本可能是什么样子。
如果脚本很短,为每一行添加前缀and可能不会太糟糕:
cp file1 file2
and rm file1
and echo File moved