Pergunta

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?

Foi útil?

Solução

There's no equivalent of this in fish. https://github.com/fish-shell/fish-shell/issues/805 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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top