看到这个脚本,我试图弄清楚使用的是什么语言......它几乎就像 C 但我注意到 fi 作为关闭嵌套 if 的一种方式。
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
}
最佳答案
这段代码是Unix shell。但问题的答案
what language uses “fi”
有点长。镜像词的用法,如
if
和 fi
或 case
和 esac
来自 Algol,一个很好的总结见 comparison of languages .它是 Stephen Bourne他把这个从 Algol 带到了 Unix shell,他首先在 Algol 上工作,后来在 sh
和 adb
早期的 Unix 系统。他非常喜欢这种语法,甚至 C
他为 sh
编写的代码和 adb
由于一堆预处理器宏,看起来像 Algol。好奇的可以看看source code of sh的2.11BSD源代码或 adb .毕竟它编译为C。所以即使在 C 中也可以找到 FI
当回溯到很远的历史时。
关于shell - 什么语言使用 "fi",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6310008/