mdesantis mdesantis - 1 year ago 100
Bash Question

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

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?

Answer Source

There's no equivalent of this in fish. spend a little time discussing what a fishy version of this might look like.

If the script is short, prefixing each line with and might not be too bad:

cp file1 file2
and rm file1
and echo File moved
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download