On bash you can use set -e
inside a script in order to exit on error:
set -e
cd unexisting-folder
echo "this line will not be printed"
But on fish shell set -e
is used to erase variables:
set FOO bar
set -e FOO
echo {$FOO} # prints newline
What is the equivalent of Bash set -e
on Fish?
set -e
is a bad idea in bash, where consistent use of|| return
or|| exit
(like the fishor return
suggested by Fractale below) is the more reliable practice. – Amadavat