[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: WANTED: POSIX compatible getopt
- From: Rob Kendrick <lua-l@...>
- Date: Fri, 9 Jan 2009 14:51:18 +0000
On Fri, 09 Jan 2009 16:40:43 +0200
Aleksey Cheusov <email@example.com> wrote:
> > On Fri, Jan 9, 2009 at 9:19 AM, Aleksey Cheusov <firstname.lastname@example.org>
> > wrote:
> >> http://lua-users.org/wiki/AlternativeGetOpt
> >> doesn't look good too.
> > looks clean to me. what's bad with this?
> 1) This code is not versioned. I'd prefer to use code
> registered somewhere as a separate project, e.g. luaforge.
> I'd like to package getopt for pkgsrc (www.pkgsrc.org)
Put it in a version control system, then >:)
> 2) `--' is not processed correctly, processing the args should be
> stopped at `--'.
Or rather, -- followed directly by white space or EOL.
> 3) `-' (meaning stdin) is not processed correctly, the same as 2)
I've always handled this myself, outside of getopt. Mainly because
getopt doesn't assume things are filenames, because they might not be.
> 4) `--long-opt value' is not handled correctly
Looks easy to fix.
> This code doesn't do what I need and is not compatible with SUS/POSIX.
Where does POSIX define command line option parsing?
Have you considered just writing a little C code to bind the C
library's getopt? It requires some dancing; you have to split the
string up yourself, etc. (Although you could do that easily with a
little Lua wrapper function calling the string functions.)