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

标签 shell fish

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

if ! prog ...
  ....

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

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

最佳答案

您正在寻找 not关键词:

if not false
   echo Foo
end

关于shell - 如何为fish shell中的if语句否定程序的错误代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37278965/

相关文章:

linux - 将大文件分割成小文件的更快方法?

bash - 在单引号字符串中的 bash 中转义单引号

shell - 如何在fish shell中设置环境变量

permission-denied - 如何解析 fish : Unable to open temporary file '/opt/PhpStorm-191.6707.66/plugins/terminal/fish/fishd.tmp.6SUNyz' : Permission denied

fish - 如何从 fish shell 中的除法中获得十进制值

linux - 在fish shell中定义别名

bash - awk 子替换中的奇怪行为

Bash Shell 参数扩展 ${ }

shell 脚本 : Count number of files in a particular type extension in single folder

fish shell : how to append an element to an array