Sublime 构建 exec 命令数组

Sublime build exec command array

我很困惑为什么 Sublime Text 2 构建系统倾向于将 exec 命令作为数组放置。虽然这在文档中有建议(并且可行),但将命令作为字符串也同样有效,并且(在我看来)更直接。

Sublime Text 构建系统使用subprocess.Popen,推荐使用数组。否则解释是平台相关的。

引用自python 2 subprocess documentation:

args should be a sequence of program arguments or else a single string. By default, the program to execute is the first item in args if args is a sequence. If args is a string, the interpretation is platform-dependent (...). Unless otherwise stated, it is recommended to pass args as a sequence.

其他重要引用(感谢@Dimpl 指出):

The shell argument (which defaults to False) specifies whether to use the shell as the program to execute. If shell is True, it is recommended to pass args as a string rather than as a sequence.

如果您使用 shell_cmdFalse True True [=12] =].因此,根据引用,我建议对 cmd 使用数组,对 shell_cmd.

使用字符串