为什么在这个Bash脚本中使用$符号

4
我正在查看Fedora SysV初始化脚本示例,其内容如下:

我正在查看Fedora SysV初始化脚本示例,其内容如下:

#...some code
 start() {
    [ -x $exec ] || exit 5
    [ -f $config ] || exit 6
    echo -n $"Starting $prog: "
    # if not running, start it up here, usually something like "daemon $exec"
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
#...some more code....

这行代码中第一个美元符号的原因是什么?即使没有它,脚本似乎也可以正常工作 - 对吗?
echo -n $"Starting $prog: "
1个回答

6

你能提供文档链接或者至少一个来源吗? - jtbandes
@jtbandes:我正在寻找一些,但很难找到。 - Ignacio Vazquez-Abrams
嗯,这里有一个例子,但它们使用括号:http://docs.unity-linux.org/I18n_Support_and_Shell_Scripts - Stann
@Andre:那是因为那是完全不同的机制。 - Ignacio Vazquez-Abrams
1
这是链接:http://www.gnu.org/software/bash/manual/bashref.html#Major-Differences-From-The-Bourne-Shell,它是第10个项目符号,链接到http://www.gnu.org/software/bash/manual/bashref.html#Locale-Translation。 - Keith Thompson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接