Popen Question
Hans Mulder
hansmu at xs4all.nl
Mon Nov 8 17:35:13 EST 2010
Ian wrote:
> On Nov 8, 2:43 am, m... at distorted.org.uk (Mark Wooding) wrote:
>>> I don’t know what happens to the extra arguments, but they just seem
>>> to be ignored if -c is specified.
>> The argument to -c is taken as a shell script; the remaining arguments
>> are made available as positional parameters to the script as usual (only
>> starting with $0 rather than $1, for some unknown reason).
>
> Perhaps this example better demonstrates what is going on:
>
>>>> p = subprocess.Popen(['echo one $0 three $1 five', 'two', 'four'],
> ... shell=True)
> one two three four five
Maybe I'm thick, but I still don't understand. If I run a shell script,
then the name of the script is in $0 and the first positional arguments
is in $1, similar to how Python sets up sys.argv.
But in this case the first positional argument is in $0. Why is that?
Puzzled,
-- HansM
More information about the Python-list
mailing list