[stdlib-sig] quoting arguments for command-line evaluation
Bill Janssen
janssen at parc.com
Mon May 24 18:23:25 CEST 2010
C. Titus Brown <ctb at msu.edu> wrote:
> On Mon, May 24, 2010 at 07:46:32AM -0700, Bill Janssen wrote:
> > I'm kind of surprised to see that the subprocess module doesn't have a
> > documented function for calling to properly quote command-line
> > arguments. Nor does it seem to do so automatically -- at least on Unix.
>
> Bill, I may be about to reveal my profound ignorance here, but...
>
> do you need to quote arguments passed as a list on UNIX? My impression
> was that if shell=False, then it wasn't needed.
Yes, that's right. You need to quote them only if you are passing a
whole command line to be evaluated as a shell, as with os.system() or
shell=True and args a string with subprocess. I think subprocess gets
all this more or less right.
In my case, I was building up a command line to pass as a single string
to subprocess, and needed a way to quote the args explicitly. That's
why I went looking at this.
Bill
More information about the stdlib-sig
mailing list