Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to negate a program's error code for an if statement in fish shell?

Tags:

shell

fish

I wanted to do something like either of these statements, that is probably like bash, but received errors:

if ! prog ...
  ....

Error: fish: Unknown command '! prog ...'

if test ! prog ...
  ....

Error: test: Expected a combining operator like '-a' at index 2

like image 780
Pysis Avatar asked May 17 '16 14:05

Pysis


1 Answers

You're looking for the not keyword:

if not false
   echo Foo
end
like image 54
Zanchey Avatar answered Sep 24 '22 11:09

Zanchey