Shebang (#!) 是否标准化?
Is the Shebang (#!) standardized?
是Shebang#!
,例如
#!/bin/sh
在 Linux 标准库或任何 The Open Group 标准或其他地方正式标准化的脚本可执行文件前面?如果是,请提供参考资料和详细信息。
注意:我最感兴趣的是它对 shell 脚本以及任何可执行文件的含义。换句话说,是否有任何标准要求在可执行文件的开头对 #!
进行类似 shebang 的解释?但是,也欢迎在标准中引用它。
POSIX 未指定 #!
的效果。来自2.1Shell介绍
The shell reads its input from a file (see sh), from the -c option or from the system() and popen() functions defined in the System Interfaces volume of POSIX.1-2008. If the first line of a file of shell commands starts with the characters "#!", the results are unspecified.
来自source:
Bash scripts often begin with #! /bin/bash (assuming that Bash has
been installed in /bin), since this ensures that Bash will be used to
interpret the script, even if it is executed under another shell.
你也可以查看这个The #! magic, details about the shebang/hash-bang mechanism on various Unix flavours
是Shebang#!
,例如
#!/bin/sh
在 Linux 标准库或任何 The Open Group 标准或其他地方正式标准化的脚本可执行文件前面?如果是,请提供参考资料和详细信息。
注意:我最感兴趣的是它对 shell 脚本以及任何可执行文件的含义。换句话说,是否有任何标准要求在可执行文件的开头对 #!
进行类似 shebang 的解释?但是,也欢迎在标准中引用它。
POSIX 未指定 #!
的效果。来自2.1Shell介绍
The shell reads its input from a file (see sh), from the -c option or from the system() and popen() functions defined in the System Interfaces volume of POSIX.1-2008. If the first line of a file of shell commands starts with the characters "#!", the results are unspecified.
来自source:
Bash scripts often begin with #! /bin/bash (assuming that Bash has been installed in /bin), since this ensures that Bash will be used to interpret the script, even if it is executed under another shell.
你也可以查看这个The #! magic, details about the shebang/hash-bang mechanism on various Unix flavours