On Mon, May 24, 2010 at 11:23 AM, Bill Janssen <span dir="ltr">&lt;<a href="mailto:janssen@parc.com">janssen@parc.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div class="im">C. Titus Brown &lt;<a href="mailto:ctb@msu.edu">ctb@msu.edu</a>&gt; wrote:<br>
<br>
&gt; On Mon, May 24, 2010 at 07:46:32AM -0700, Bill Janssen wrote:<br>
&gt; &gt; I&#39;m kind of surprised to see that the subprocess module doesn&#39;t have a<br>
&gt; &gt; documented function for calling to properly quote command-line<br>
&gt; &gt; arguments. Â Nor does it seem to do so automatically -- at least on Unix.<br>
&gt;<br>
&gt; Bill, I may be about to reveal my profound ignorance here, but...<br>
&gt;<br>
&gt; do you need to quote arguments passed as a list on UNIX? Â My impression<br>
&gt; was that if shell=False, then it wasn&#39;t needed.<br>
<br>
</div>Yes, that&#39;s right. Â You need to quote them only if you are passing a<br>
whole command line to be evaluated as a shell, as with os.system() or<br>
shell=True and args a string with subprocess. Â I think subprocess gets<br>
all this more or less right.<br>
<br>
In my case, I was building up a command line to pass as a single string<br>
to subprocess, and needed a way to quote the args explicitly. Â That&#39;s<br>
why I went looking at this.<br clear="all"></blockquote><div> <br>I&#39;ve had to do this sort of thing for similar reasons, like calling remote ssh commands, where a shell command is embedded in a positional argument.  I implemented my own thing, but the way pipes.quote works would have been nicer (the implementation could use a couple regexes instead of iterating over strings though).<br>

</div></div><br>-- <br>Ian Bicking Â | Â <a href="http://blog.ianbicking.org">http://blog.ianbicking.org</a><br>