什么语言使用“fi”
问题描述:
看到这个脚本,我想弄清楚什么语言被使用......它几乎像C但我注意到了fi作为关闭嵌套if的方法。什么语言使用“fi”
function prompt() {
if [ "$noprompt" ] && [ "$#" = "1" ]; then
if [ "$1" = "yes" ]; then
echo "DEFAULT: yes"
return 0
else
echo "DEFAULT: no"
return 1
fi
fi
while true; do
echo "Enter \"yes\" or \"no\": "
read response
case $response
in
Y*) return 0 ;;
y*) return 0 ;;
N*) return 1 ;;
n*) return 1 ;;
*)
esac
done
}
答
看起来像一个shell脚本 - bash,也许。
答
这段代码是Unix shell。但是,问题的答案
什么语言使用“网络连接”
是有点长。 镜像文字的用法,如if
和fi
或case
和esac
来自Algol,其中有一个很好的总结请参见comparison of languages。这是从Algol到Unix shell的Stephen Bourne,他首先在Algol上工作,后来在早期的Unix系统的sh
和adb
上工作。他非常喜欢这种语法,即使他为sh
和adb
编写的C
代码看起来像Algol,这要归功于一堆预处理器宏。好奇心可以看看source code of sh或adb的2.11BSD源代码。毕竟它编译为C.因此,即使在C中,当历史悠久时,也能找到FI
。
Shell脚本。可能是sh,bash或类似的 – Dirk 2011-06-10 17:33:25