[pacman-dev] [PATCH] Added the function parse_options to replace getopt

Allan McRae allan at archlinux.org
Mon Dec 22 06:39:16 EST 2008


Allan McRae wrote:
> Allan McRae wrote:
>> Dan McGee wrote:
>>> On Mon, Dec 8, 2008 at 8:22 AM, Yun Zheng Hu <yunzheng.hu at gmail.com> 
>>> wrote:
>>>  
>>>>> Just letting the submitter know that this patch is being looked 
>>>>> at.  I have
>>>>> a getopt branch on my git repo where this will receive more 
>>>>> testing before
>>>>> it gets pulled in.  From my current testing, it looks good and we 
>>>>> seem to
>>>>> have lost no functionality.
>>>>>
>>>>>       
>>>> Do you think this can make it to the pacman 3.2.3 release?
>>>>     
>>>
>>> We (Allan and I) talked about this last night a bit. I would like to
>>> get it in, but with a maint release especially, we don't want to have
>>> regressions.
>>>   
>>
>> I will try and find time to give it a thorough review in the next 
>> couple of days and see if we can get it in.
>
> I've given this a fairly thorough testing now.  It even managed to 
> deal properly with passing an argument with a space in it (which is 
> where I thought it may fail...). It does not put unused stuff at the 
> end, but makepkg actually does nothing about those so this does not 
> really matter...
>
> e.g.  outputting $OPT_TEMP
>
> Not patched
> ./makepkg --log -p "BUILD SCRIPT" foobar
> ==>  --log -p 'BUILD SCRIPT' -- 'foobar'
>
> Patched
> ./makepkg2 --log -p "BUILD SCRIPT" foobar
> ==>  --log -p 'BUILD SCRIPT' --
>
> It would be nice to do something about adding the unused values at the 
> end in case we ever do something with them but that should be a simple 
> fix.  I can probably add this tomorrow and pull the patch onto my 
> working branch.

I found some other differences too.  makepkg = original, makepkg2 = this 
patch

 > ./makepkg -psr
==>  -p 'sr' --

 > ./makepkg2 -psr
==>  -p '' --


 > ./makepkg -sp
makepkg: option requires an argument -- 'p'
==>  -s --
GETOPT GO BANG!

 > ./makepkg2 -sp
makepkg: option requires an argument -- 'sp'
==>  -s -p --
PARSE_OPTIONS FAILED


And just for completeness....

 > ./makepkg fakeroot -- -s -r
==>  -- 'fakeroot' '-s' '-r'

 > ./makepkg2 fakeroot -- -s -r
==>  -- '-s' '-r'

I have fixed/rewritten the patch and will send it here soon.

Allan





More information about the pacman-dev mailing list