Fish: how to exit with an error (bash set -e)

In bash, you can use set -e inside a script to exit with an error:

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

But for a fish shell, set -e used to erase variables:

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

What is the equivalent of bash set -e for Fish?

+8
bash shell fish error-handling
source share
1 answer

There is no equivalent to this in fish. https://github.com/fish-shell/fish-shell/issues/805 spend some time discussing what might seem like a fish version.

If the script is short, the prefix of each line with and may not be too bad:

 cp file1 file2 and rm file1 and echo File moved 
+8
source share

All Articles