I am confused as to why Sublime Text 2 build systems tend to put the exec command as an array. Though this is suggested in the docs (and works), just putting the command as a string works just as well, and is (in my opinion) more straightforward.
-
1The Sublime Text build system calls `subprocess.Popen`, which recommends the usage of an array. Otherwise the behavior is platform-dependent and a string has a significant different behavior on non-Windows systems. Read more in the [docs](https://docs.python.org/2/library/subprocess.html#popen-constructor). – r-stein Mar 07 '16 at 15:07
-
If you want to put that in as an answer, I'll close the question. – Dimpl Mar 09 '16 at 02:36
1 Answers
The Sublime Text build system uses subprocess.Popen
, which recommends the usage of an array. Otherwise the interpretation is platform-dependent.
Cited from the 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.
Additional important cite (thanks @Dimpl for pointing that out):
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.
The shell argument is set True if you use the shell_cmd
and False for cmd
. Hence based on the cites I would suggest to use an array for cmd
and a string for shell_cmd
.

- 4,627
- 2
- 16
- 27
-
1Note (from the above-cited documentation): 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. – Dimpl Mar 10 '16 at 13:07