zh-google-styleguide/google-shell-styleguide/shell_files_and_interpreter_invocation.rst
2016-03-19 19:44:56 +08:00

24 lines
1.1 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Shell文件和解释器调用
===============================
文件扩展名
--------------------
.. tip::
可执行文件应该没有扩展名(强烈建议)或者使用.sh扩展名。库文件必须使用.sh作为扩展名而且应该是不可执行的。
当执行一个程序时并不需要知道它是用什么语言编写的。而且shell脚本也不要求有扩展名。所以我们更喜欢可执行文件没有扩展名。
然而,对于库文件,知道其用什么语言编写的是很重要的,有时候会需要使用不同语言编写的相似的库文件。使用.sh这样特定语言后缀作为扩展名就使得用不同语言编写的具有相同功能的库文件可以采用一样的名称。
SUID / SGID
--------------------
.. tip::
SUID(Set User ID)和SGID(Set Group ID)在shell脚本中是被禁止的。
shell存在太多的安全问题以致于如果允许SUID/SGID会使得shell几乎不可能足够安全。虽然bash使得运行SUID非常困难但在某些平台上仍然有可能运行这就是为什么我们明确提出要禁止它。
如果你需要较高权限的访问请使用 ``sudo``