我正在浏览 Fish shell 教程,发现这个简单的 if-else 块不起作用
if grep fish /etc/shells
echo Found fish
else if grep bash /etc/shells
echo Found bash
else
echo Got nothing
end
错误信息:
/usr/bin/fish
Found fish
fish: global root block
fish: Could not locate end of block. The 'end' command is missing, misspelled or
a ';' is missing.
end - end a block of commands.
答案1
可能您安装了非常旧的 (1.x) 版本的 Fish,它早于 else-if 构造。输出什么fish --version
?理想情况下您需要 2.1.0。