[pacman-dev] [PATCH] makepkg : switch from getopt to getopts builtin

Dan McGee dpmcgee at gmail.com
Mon Jun 2 12:29:56 EDT 2008


On Mon, Jun 2, 2008 at 11:15 AM, Allan McRae <mcrae_allan at hotmail.com> wrote:
> Alessio Bolognino wrote:
>> On Mon 2008-06-02 11:54, Xavier wrote:
>>
>>> >From f5c5a277e2df14650ae441f32950aa6d4deee50f Mon Sep 17 00:00:00 2001
>>> From: Xavier Chantry <shiningxc at gmail.com>
>>> Date: Wed, 28 May 2008 21:57:28 +0200
>>> Subject: [PATCH] makepkg : switch from getopt to getopts builtin
>>>
>>> getopt is an external script for parsing and is less portable than getopts
>>> which is a bash builtin.
>>> The main problem is that it only supports short opts, so long opts had to be
>>> dropped.
>>> The benefits are a much better portability and a simpler code for the
>>> arguments parsing.
>>>
>>
>> Maybe dropping all long options is not a great idea: makepkg has a lot
>> of options and find an alphanumeric character for each is not that
>> easy/intuitive; Furthermore getopt is ported virtually everywhere: Mac
>> OS X, FreeBSD, OpenBSD, NetBSD etc. and stuff like asciidoc
>> depends upon it.
>>
>>
>
> Wasn't the whole point of this that getopt didn't work properly/as
> expected on BSD?
>
>> Bear in mind I don't have a strong opinion about that, I was just
>> playing devil's advocate :)
>>
>
> Well, I am not a fan!  Has anybody looked into parsing options
> manually?  I seem to recall Xavier point out a bash implementation that
> could be used.  makepkg does not have anything too complex (options take
> one arg max) so it should be fairly easy.  I'd much prefer a
> parse_options function to be added than to lose all the long options.
> However, if that proves too complex a solution, I will graciously accept
> defeat...

I won't graciously accept it! :)

I'd much rather keep longopts, so I think a parse_options() function
that uses getopts in combo with some manual longopt parsing is our
best bet.

-Dan




More information about the pacman-dev mailing list