Bash - “fi ;”有什么用?
我一直在到处寻找解释。下面是一个取自 apt-fast.sh 脚本的真实示例:
if [ ! -x /usr/bin/axel ]
then echo "axel is not installed, perform this?(y/n)"
read ops
case $ops in
y) if apt-get install axel -y --force-yes
then echo "axel installed"
else echo "unable to install the axel. you are using sudo?" ; exit
fi ;;
n) echo "not possible usage apt-fast" ; exit ;;
esac
fi
if
块中间的 "fi ;;"
有什么用?
I have been searching everywhere for an explanation. Here's a real example taken from the apt-fast.sh script:
if [ ! -x /usr/bin/axel ]
then echo "axel is not installed, perform this?(y/n)"
read ops
case $ops in
y) if apt-get install axel -y --force-yes
then echo "axel installed"
else echo "unable to install the axel. you are using sudo?" ; exit
fi ;;
n) echo "not possible usage apt-fast" ; exit ;;
esac
fi
What's the use of "fi ;;"
in the middle of the if
block?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
fi
关闭if
语句,而;;
关闭case
语句中的当前条目。fi
closes theif
statement, while;;
closes the current entry in thecase
statement.fi
用于关闭y)
case 语句中的 if 块,;;
用于结束y)
案例。The
fi
is to close the if-block in they)
case statement and the;;
is used to end they)
case.fi
终止前面的if
,而;;
终止case.. 中的
。y)
情况。 .esacfi
terminates the precedingif
, while;;
terminates they)
case in thecase...esac
.fi
关闭打开 3 行的if
语句。;;
关闭由y)
打开的案例。fi
closes theif
statement opened 3 lines up.;;
closes the case opened byy)
.