鱼壳:如何在出错时退出(bash set-e)

鱼壳:如何在出错时退出(bash set-e),bash,shell,error-handling,fish,Bash,Shell,Error Handling,Fish,在bash上,您可以在脚本中使用set-e,以便在出现错误时退出: set -e cd unexisting-folder echo "this line will not be printed" 但在鱼壳set上-e用于擦除变量: set FOO bar set -e FOO echo {$FOO} # prints newline 鱼的Bashset-e的等价物是什么。花一点时间讨论一下这个可疑的版本可能是什么样子 如果脚本很短,则在每行前面加上和可能不会太糟糕: cp file1 fi

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

set -e
cd unexisting-folder
echo "this line will not be printed"
但在鱼壳
set上-e
用于擦除变量:

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

鱼的Bash
set-e
的等价物是什么。花一点时间讨论一下这个可疑的版本可能是什么样子

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

cp file1 file2
and rm file1
and echo File moved