【发布时间】:2010-05-29 19:16:47
【问题描述】:
在我的服务器 (linux) 上的文件的开头,该文件位于 /etc/init.d/ 文件夹中,我有这一行:
!/bin/sh -e
这是什么意思,因为每次我执行脚本的其余部分时它都可以正常工作,除了显示以下错误:
!/bin/sh not found
有什么想法吗?
【问题讨论】:
-
到目前为止,还没有人处理
-e,这似乎不是我 MacBook 上 bash 接受的标志。 -
@dmckee: sh != bash。
man sh(或man dash)显示-e errexit: If not interactive, exit immediately if any untested command fails... -
顺便说一下@Camran,它仍然在没有修复shebang行的情况下运行的原因可能是因为您直接调用了shell解释器,例如
sh myScript。使用 shebang 行,您可以使用chmod +x...将文件设置为可执行并在不显式调用解释器的情况下运行它。 -
@Mark:我知道。但是 Mac OS X 没有普通的 bourne shell,而且我手边也没有 linux 盒子……