FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 06-02-2008, 04:29 PM
"Dan McGee"
 
Default makepkg : switch from getopt to getopts builtin

On Mon, Jun 2, 2008 at 11:15 AM, Allan McRae <mcrae_allan@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@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

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 06-03-2008, 08:45 AM
Xavier
 
Default makepkg : switch from getopt to getopts builtin

On Mon, Jun 2, 2008 at 5:11 PM, Alessio Bolognino <themolok.ml@gmail.com> wrote:
>
> 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.
>

The reason of that patch is that the different getopt implementations
are not compatible :
http://www.archlinux.org/pipermail/pacman-dev/2008-May/011857.html
The arguments parsing currently does not work on osx / bsd.

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 06-03-2008, 08:49 AM
Xavier
 
Default makepkg : switch from getopt to getopts builtin

On Mon, Jun 2, 2008 at 6:29 PM, Dan McGee <dpmcgee@gmail.com> wrote:
>
> 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.
>

Ok so let's just revert to the old way:
http://www.archlinux.org/pipermail/pacman-dev/2008-May/011858.html

You can see the loop was approximately twice longer because longopts
and shortopts are handled separately, but it might be the best
compromise.

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 06-03-2008, 09:50 AM
"Roman Kyrylych"
 
Default makepkg : switch from getopt to getopts builtin

2008/6/3 Xavier <shiningxc@gmail.com>:
> On Mon, Jun 2, 2008 at 6:29 PM, Dan McGee <dpmcgee@gmail.com> wrote:
>>
>> 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.
>>
>
> Ok so let's just revert to the old way:
> http://www.archlinux.org/pipermail/pacman-dev/2008-May/011858.html
>
> You can see the loop was approximately twice longer because longopts
> and shortopts are handled separately, but it might be the best
> compromise.

Sounds reasonable.

--
Roman Kyrylych (*оман Кирилич)
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 06-03-2008, 02:57 PM
Xavier
 
Default makepkg : switch from getopt to getopts builtin

On Tue, Jun 3, 2008 at 4:32 PM, Alessio Bolognino <themolok.ml@gmail.com> wrote:
>
> Actually FreeBSD and NetBSD have in their port tree "getopt", which is
> this one: http://software.frodo.looijaard.name/getopt/
> as you can see, is the same getopt in util-linux;
> in OpenBSD's tree is called gnugetopt, but it's still the same software.
> In Mac OS X it can be installed with macports, and it's called "getopt".
>

Now I am confused. Do they all include a getopt in their base system,
for example as /bin/getopt , and then external getopt which install as
/usr/bin/getopt or something?
The binary name is getopt on all except on openbsd where it is
gnugetopt? Or were you just talking about the package / port name?

In any cases, this is very interesting, are you able to check it to be
sure it works? Or anyone else?

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 06-03-2008, 03:22 PM
"Dan McGee"
 
Default makepkg : switch from getopt to getopts builtin

On Tue, Jun 3, 2008 at 9:57 AM, Xavier <shiningxc@gmail.com> wrote:
> On Tue, Jun 3, 2008 at 4:32 PM, Alessio Bolognino <themolok.ml@gmail.com> wrote:
>>
>> Actually FreeBSD and NetBSD have in their port tree "getopt", which is
>> this one: http://software.frodo.looijaard.name/getopt/
>> as you can see, is the same getopt in util-linux;
>> in OpenBSD's tree is called gnugetopt, but it's still the same software.
>> In Mac OS X it can be installed with macports, and it's called "getopt".
>>
>
> Now I am confused. Do they all include a getopt in their base system,
> for example as /bin/getopt , and then external getopt which install as
> /usr/bin/getopt or something?
> The binary name is getopt on all except on openbsd where it is
> gnugetopt? Or were you just talking about the package / port name?
>
> In any cases, this is very interesting, are you able to check it to be
> sure it works? Or anyone else?

Yeah, I'm confused as well, wow. I didn't know it was this complex of
a situation.

I would love to see the following:
1. Where does getopt definitely work and definitely not work "out of the box"?
2. Where is (GNU) getopt available if it is installed?

At first I was convinced we shouldn't use it, but now not so much.

-Dan

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 06-03-2008, 05:50 PM
"Dan McGee"
 
Default makepkg : switch from getopt to getopts builtin

On Tue, Jun 3, 2008 at 12:31 PM, Alessio Bolognino
<themolok.ml@gmail.com> wrote:
> On Tue 2008-06-03 10:22, Dan McGee wrote:
>> On Tue, Jun 3, 2008 at 9:57 AM, Xavier <shiningxc@gmail.com> wrote:
>> > On Tue, Jun 3, 2008 at 4:32 PM, Alessio Bolognino <themolok.ml@gmail.com> wrote:
>> >>
>> >> Actually FreeBSD and NetBSD have in their port tree "getopt", which is
>> >> this one: http://software.frodo.looijaard.name/getopt/
>> >> as you can see, is the same getopt in util-linux;
>> >> in OpenBSD's tree is called gnugetopt, but it's still the same software.
>> >> In Mac OS X it can be installed with macports, and it's called "getopt".
>> >>
>> >
>> > Now I am confused. Do they all include a getopt in their base system,
>> > for example as /bin/getopt , and then external getopt which install as
>> > /usr/bin/getopt or something?
>> > The binary name is getopt on all except on openbsd where it is
>> > gnugetopt? Or were you just talking about the package / port name?
>> >
>> > In any cases, this is very interesting, are you able to check it to be
>> > sure it works? Or anyone else?
>>
>> Yeah, I'm confused as well, wow. I didn't know it was this complex of
>> a situation.
>>
>> I would love to see the following:
>> 1. Where does getopt definitely work and definitely not work "out of the box"?
>
> By default GNU getopt is not installed on BSDs.
>
>> 2. Where is (GNU) getopt available if it is installed?
>
> In Mac OS X is /opt/local/bin/getopt ,
> in OpenBSD is /usr/local/bin/gnugetopt ,
> in FreeBSD probably is /usr/local/bin/getopt ,
> in NetBSD is $somewhere/getopt
>
>> At first I was convinced we shouldn't use it, but now not so much.
>
> I don't know if this is acceptable, but we could use a function in makepkg
> to find the *right* getopt, something like:
>
> ------------8<-------------------8<-------------------8<---------------
> getopt=""
> for x in `echo $PATH | sed s@:@ @g`; do
> for y in getopt gnugetopt; do
> if [[ -x $x/$y ]]; then
> $x/$y --version 2>&1 | grep getopt &>/dev/null
> if [[ $? == 0 ]] && [[ -z $getopt ]]; then
> getopt=$x/$y
> fi
> fi
> done
> done
> echo $getopt
> ----------->8------------------->8------------------->8----------------
>
> (It works because GNU getopt prints "getopt (enhanced) 1.1.4" and BSD
> getopt prints "--")
>
> Yeah, it's ugly.

getopt -T looks like the winner for deciding whether we have a valid
getopt version installed. That doesn't solve the parsing issues
though.

-Dan

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 07-09-2008, 09:02 AM
Sebastian Nowicki
 
Default makepkg : switch from getopt to getopts builtin

Ping.

Was there any decision made about this?
If the getopts on the different platforms are compatible, there
wouldn't be any parsing issues, would there?____________________________________________ ___
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 07-09-2008, 09:16 AM
Xavier
 
Default makepkg : switch from getopt to getopts builtin

On Wed, Jul 9, 2008 at 11:02 AM, Sebastian Nowicki <sebnow@gmail.com> wrote:
> Ping.
>
> Was there any decision made about this?
> If the getopts on the different platforms are compatible, there wouldn't be
> any parsing issues, would there?

I don't think so, that was the whole purpose of checking for gnu getopt.

I don't even know which parsing issues Dan was talking about, parsing
issues when using getopt for parsing arguments, or parsing issues
inside the "gnu getopt detection" of Alessio or something else.

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 07-11-2008, 11:51 AM
Sebastian Nowicki
 
Default makepkg : switch from getopt to getopts builtin

I just installed GNU getopt manually (not using macports) to /usr/
local on Mac OS X Leopard, and it seems to work fine. The only
"problem" is that you have to modify PATH so that /usr/local is
before /usr/bin so that the right one gets used. The "gnu getopt
finder" code that Alessio would solve the problem (if it works
properly).


I haven't been able to test it on BSD yet.______________________________________________ _
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 

Thread Tools




All times are GMT. The time now is 03:14 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org