我正在自学bash,并使用学习bash Shell这样做.
我注意到在流控制中我们定义了一个if/else语句:
if [ statement_is_true ]; then
# do stuff here
elif [ some_other_statement]; then
# other thing
else
# if all else fails
fi
Run Code Online (Sandbox Code Playgroud)
以及一个案例陈述:
case $expr in
case1 )
;;
case2 )
;;
esac
Run Code Online (Sandbox Code Playgroud)
但是for循环可能被定义为
for i in $list;
do
# something cool with the various $i
done
Run Code Online (Sandbox Code Playgroud)
和一个循环作为
while [ condition ]; do
# something that loops
done
Run Code Online (Sandbox Code Playgroud)
为什么结束for,while以及until循环标注done,而不是rof,elihw和litnu分别,喜欢if/fi和case/esac建设?(或者,它为什么不if/fi代替if/done?