[pacman-dev] [PATCH] makepkg : switch from getopt to getopts builtin
Dan McGee
dpmcgee at gmail.com
Tue Jun 3 13:50:05 EDT 2008
On Tue, Jun 3, 2008 at 12:31 PM, Alessio Bolognino
<themolok.ml at gmail.com> wrote:
> On Tue 2008-06-03 10:22, Dan McGee wrote:
>> On Tue, Jun 3, 2008 at 9:57 AM, Xavier <shiningxc at gmail.com> wrote:
>> > On Tue, Jun 3, 2008 at 4:32 PM, Alessio Bolognino <themolok.ml at 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
More information about the pacman-dev
mailing list