[issue30079] Explain why it is recommended to pass args as a string rather than as a sequence If shell is True

2017-04-16 Thread R. David Murray
R. David Murray added the comment: Woops, cut and paste error, there should have been an "echo $2" line in that script as well. -- ___ Python tracker

[issue30079] Explain why it is recommended to pass args as a string rather than as a sequence If shell is True

2017-04-16 Thread R. David Murray
R. David Murray added the comment: Note the subtlety here on unix: rdmurray@pydev:~/python/p36[3.6]>cat temp.sh #!/bin/bash echo $0 echo $1 >>> subprocess.call(['./temp.sh', 'spam', 'eggs'], shell=True) ./temp.sh 0 >>> subprocess.call(['./temp.sh $0 $1', 'spam', 'eggs'], shell=True)

[issue30079] Explain why it is recommended to pass args as a string rather than as a sequence If shell is True

2017-04-15 Thread Eryk Sun
Eryk Sun added the comment: In Unix, passing an args list with shell=True makes the first element the -c command. The remaining elements are arguments for the shell itself, which makes them $N variables. For example: >>> subprocess.call(['echo $0, $1', 'spam', 'eggs'], shell=True)

[issue30079] Explain why it is recommended to pass args as a string rather than as a sequence If shell is True

2017-04-15 Thread R. David Murray
R. David Murray added the comment: Because passing a sequence to shell=True won't work on unix. It only works more-or-less by accident on windows, even though the current docs kind of encourage it. Yes, I think it would be good if these sentences were clarified. See also issue 7839.

[issue30079] Explain why it is recommended to pass args as a string rather than as a sequence If shell is True

2017-04-15 Thread Philip Lee
New submission from Philip Lee: The doc here https://docs.python.org/3/library/subprocess.html#subprocess.Popen says : "If shell is True, it is recommended to pass args as a string rather than as a sequence." but without explain why ? Please add the explanation ! while in