如何否定fish shell中if语句的程序错误代码?

Pys*_*sis 4 shell fish

我想做一些像这些语句中的任何一个,这可能像bash,但收到错误:

if ! prog ...
  ....
Run Code Online (Sandbox Code Playgroud)

错误: fish: Unknown command '! prog ...'

if test ! prog ...
  ....
Run Code Online (Sandbox Code Playgroud)

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

Zan*_*hey 8

您正在寻找not关键字:

if not false
   echo Foo
end
Run Code Online (Sandbox Code Playgroud)