【问题标题】:what language uses "fi"什么语言使用“fi”
【发布时间】:2011-06-10 17:30:59
【问题描述】:

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

【问题讨论】:

  • Shell 脚本。可能是 sh、bash 或类似的

标签: shell


【解决方案1】:

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

什么语言使用“fi”

有点长。 镜像词的用法,如ifficaseesac 来自Algol,有关摘要,请参见comparison of languages。是 Stephen Bourne 将它从 Algol 带到 Unix shell,他首先在 Algol 上工作,后来在早期 Unix 系统的 shadb 上工作。由于一堆预处理器宏,他非常喜欢这种语法,甚至他为shadb 编写的C 代码看起来也像Algol。好奇的可以看看source code of shadb的2.11BSD源码。毕竟它编译为C。因此,即使在 C 语言中,当回溯一段很长的历史时,也可以找到 FI

【讨论】:

    【解决方案2】:

    那些被 Unix Shell 脚本使用... 请参阅thisthis

    【讨论】:

      【解决方案3】:

      那是用bash shell 编写的脚本。

      【讨论】:

        【解决方案4】:

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

        【讨论】:

          【解决方案5】:

          看起来像 shell script (bash)

          【讨论】:

            【解决方案6】:

            fi 被 Unix/Linux shell 在 shell 编程中使用,
            这是if 声明。

            if [ expression ] 
            then 
               Statement(s) to be executed if expression is true 
            fi
            

            它主要由sh 命令运行

            【讨论】:

              猜你喜欢
              • 2015-07-03
              • 2015-07-19
              • 1970-01-01
              • 2011-10-24
              • 2010-11-01
              • 2010-10-17
              • 1970-01-01
              • 1970-01-01
              • 2011-06-26
              相关资源
              最近更新 更多