Bash - “fi ;;”有什么用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7010830/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bash - what's the use of "fi ;;"?
提问by Roger
I have been searching everywhere for an explanation. Here's a real example taken from the apt-fast.sh script:
我一直在到处寻找解释。这是一个取自 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
What's the use of "fi ;;"
in the middle of the if
block?
块"fi ;;"
中间有什么用if
?
回答by Nicola Musatti
fi
closes the if
statement, while ;;
closes the current entry in the case
statement.
fi
关闭if
语句,同时;;
关闭语句中的当前条目case
。
回答by Manny D
The fi
is to close the if-block in the y)
case statement and the ;;
is used to end the y)
case.
该fi
是关闭,如果块中的y)
case语句和;;
用于结束的y)
情况下。
回答by glglgl
fi
terminates the preceding if
, while ;;
terminates the y)
case in the case...esac
.
fi
终止前面的if
,而;;
终止 中的y)
情况case...esac
。
回答by hughes
fi
closes the if
statement opened 3 lines up. ;;
closes the case opened by y)
.
fi
关闭if
语句打开 3 行。;;
关闭由打开的案例y)
。