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, 03:11 PM
Alessio Bolognino
 
Default makepkg : switch from getopt to getopts builtin

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.

Bear in mind I don't have a strong opinion about that, I was just
playing devil's advocate

--
Alessio (molok) Bolognino

Please send personal email to themolok@gmail.com

Public Key http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xFE0270FB
GPG Key ID = 1024D / FE0270FB 2007-04-11
Key Fingerprint = 9AF8 9011 F271 450D 59CF 2D7D 96C9 8F2A FE02 70FB
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 06-03-2008, 02:32 PM
Alessio Bolognino
 
Default makepkg : switch from getopt to getopts builtin

On Tue 2008-06-03 10:45, Xavier wrote:
> 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.

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".

--
Alessio (molok) Bolognino

Please send personal email to themolok@gmail.com

Public Key http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xFE0270FB
GPG Key ID = 1024D / FE0270FB 2007-04-11
Key Fingerprint = 9AF8 9011 F271 450D 59CF 2D7D 96C9 8F2A FE02 70FB
_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 
Old 06-03-2008, 05:31 PM
Alessio Bolognino
 
Default makepkg : switch from getopt to getopts builtin

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.

--
Alessio (molok) Bolognino

Please send personal email to themolok@gmail.com

Public Key http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xFE0270FB
GPG Key ID = 1024D / FE0270FB 2007-04-11
Key Fingerprint = 9AF8 9011 F271 450D 59CF 2D7D 96C9 8F2A FE02 70FB
_______________________________________________
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 01:39 PM.

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