[pacman-dev] [PATCH] Fix command line argument parsing in makepkg

Sebastian Nowicki sebnow at gmail.com
Thu May 22 01:33:46 EDT 2008

On 22/05/2008, at 7:13 AM, Xavier wrote:

> Because you need to use -- to separate the getopt options from the
> argument, this is all in the manpage actually, I just figured that :)
> getopt -o abc -- $@"
> That is what makepkg does.

Yes, in GNU's getopt it works like that, but not in the BSD getopt.  
Even if "getopt -o abc -- $@" is used, you still get something like  
"-- abc -- -a -b -c", because it thinks that "-o abc -- $@" is what it  
has to process. BSD's getopt only takes the valid short options as the  
first parameter, and then the arguments to be processed [1].

> Actually I am confused. If we want to use that compatible format,  
> getopt
> abc $@, then we can't use long options anymore?

It appears so, which is very bad.

[1] http://fuse4bsd.creo.hu/localcgi/man-cgi.cgi?getopt+1

Sebastian Nowicki

More information about the pacman-dev mailing list