bash if/then/else/fi 块相当于什么鱼?

What is the fish equivalent to a bash if/then/else/fi block?

我正在使用 termux,它没有初始化系统,我在启动应用程序时找到了一个启动 crond 的脚本

if ! pgrep -f "crond" >/dev/null; then
echo "[Starting crond...]" && crond && echo "[OK]"
else
echo "[crond is running]"
fi

此代码非常适合 bash shell。

我目前正在使用 fish shell 并尝试在 bash_profile 又名 config.fish 的 fish 中使用相同的代码,但是,我收到了错误消息

Missing end to balance this if statement
if ! pgrep -f "crond" >/dev/null; then
^
from sourcing file ~/.config/fish/config.fish
         called during startup

请帮助我翻译,我正在阅读 fish 文档,但是我需要很长时间才能正确翻译。

glenn-jackman 的这个回答很有帮助

我能够 运行 config.fish 中的代码没有问题

我的代码

if ! pgrep -f $crond >/dev/null
echo "[Starting crond...]"; and crond; and echo "[OK]"
else
echo "[crond is running]"
end

老实说,你还没有努力学习任何关于鱼的知识shell。您应该从 tutorial 开始。在那里你会了解到 if 块看起来像这样:

if pgrep -f "crond" >/dev/null
    do_something
end