Bil*_*oon 16 shell env shebang
是否可以在不知道要执行的程序路径的情况下指定shebang行?
也许不指定路径
#!node
Run Code Online (Sandbox Code Playgroud)
或指定几个选项
#!/usr/local/bin/node
#!/usr/bin/node
Run Code Online (Sandbox Code Playgroud)
跨平台解决方案的额外点(各种风格的linux,BSD,OSX等......)
fav*_*tti 18
/usr/bin/env
特别考虑了跨平台解决方案.
env executes utility after modifying the environment as specified on
the command line. The option name=value specifies an environmental
variable, name, with a value of value. The option `-i' causes env
to completely ignore the environment it inherits.
If no utility is specified, env prints out the names and values of
the variables in the environment, with one name=value pair per line.
Run Code Online (Sandbox Code Playgroud)
所以有些东西:
#!/usr/bin/env node
Run Code Online (Sandbox Code Playgroud)
将跨平台和"正确的方式".