← Back to team overview

duplicity-team team mailing list archive

Re: [Merge] lp:~mterry/duplicity/argv into lp:duplicity

 

On 20.09.2013 15:18, Michael Terry wrote:
> Positive.  The first argument to exec* is the actual command to run, the first array item in argv is the "name" of the program passed to the command and is generally chopped off.
> 
> You can test this with a simple python script:
> 
> #!/usr/bin/python
> import os, sys
> print sys.argv
> if len(sys.argv) > 1:
>     os.execve(sys.argv[0], sys.argv[1:], os.environ)
> 
> $ chmod +a ./test
> $ ./test 1 2 3
> ['./test.py', '1', '2', '3']
> ['./test.py', '2', '3']
> ['./test.py', '3']
> ['./test.py']
> 

weird you're right! that's strangely not explicitely documented on the help page. ok, now i found something close to a documentation on this.
http://docs.python.org/2/library/os.html#process-management
"
The various exec*() functions take a list of arguments for the new program loaded into the process. In each case, the first of these arguments is passed to the new program as its own name rather than as an argument a user may have typed on a command line. For the C programmer, this is the argv[0] passed to a program’s main(). For example, os.execv('/bin/echo', ['foo', 'bar']) will only print bar on standard output; foo will seem to be ignored.
"

they'd better had documemted that they expect you to deliver a complete sys.argv array _incl_ the program name as argv[0]... tzzz..

anyway, nice catch.. ede

-- 
https://code.launchpad.net/~mterry/duplicity/argv/+merge/186699
Your team duplicity-team is requested to review the proposed merge of lp:~mterry/duplicity/argv into lp:duplicity.


Follow ups

References