2011-06-10 103 views
4

看到这个脚本,我想弄清楚什么语言被使用......它几乎像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 
} 
+0

Shell脚本。可能是sh,bash或类似的 – Dirk 2011-06-10 17:33:25

回答

9

那些由UNIX shell脚本使用... 见thisthis

2

看起来像一个shell脚本 - bash,也许。

4

这是一个在bash shell中编写的脚本。

5

这段代码是Unix shell。但是,问题的答案

什么语言使用“网络连接”

是有点长。 镜像文字的用法,如ifficaseesac来自Algol,其中有一个很好的总结请参见comparison of languages。这是从Algol到Unix shell的Stephen Bourne,他首先在Algol上工作,后来在早期的Unix系统的shadb上工作。他非常喜欢这种语法,即使他为shadb编写的C代码看起来像Algol,这要归功于一堆预处理器宏。好奇心可以看看source code of shadb的2.11BSD源代码。毕竟它编译为C.因此,即使在C中,当历史悠久时,也能找到FI