[issue13238] Add shell command helpers to shutil module
Nick Coghlan
report at bugs.python.org
Mon Oct 24 14:42:27 CEST 2011
Nick Coghlan <ncoghlan at gmail.com> added the comment:
Unfortunately, I don't think including implicit shlex.quote() calls is going to have the effect I was originally looking for:
>>> subprocess.call("du -hs ../py*", shell=True)
593M ../py3k
577M ../py3k_pristine
479M ../python27
300M ../python31
381M ../python32
288K ../python_swallowed_whole
0
>>> subprocess.call("du -hs {}".format(shlex.quote("../py*")), shell=True)
du: cannot access `../py*': No such file or directory
1
However, tinkering with this did provide some other "feels like using the shell" examples:
>>> subprocess.call("du -hs ~/devel", shell=True)
4.5G /home/ncoghlan/devel
0
>>> subprocess.call(["du","-hs","~/devel"])
du: cannot access `~/devel': No such file or directory
1
(I'm using the existing subprocess calls rather than the proposed API, since I'm playing with this on the current hg tip without making any changes)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13238>
_______________________________________
More information about the Python-bugs-list
mailing list