[texdoc] nonstandard arg parsing

Manuel Pégourié-Gonnard mpg at elzevir.fr
Sun Sep 21 16:59:06 CEST 2008


Karl Berry a écrit :
> It seems a command line like texdoc -iw is not understood as 
> texdoc -i -w, like nearly every other program in existence.  Does Lua
> really not have a standard getopt available?  Sigh.
> 
Probably not a standard one. Actually, before I started searching, I
thought there was no getopt at all in Lua (looks like Norbert and
Reinhard event made an attempt at it in
Master/texmf/scripts/texlive/lua/texlive).

However, a quick search raises interesting leads. There is some
getopt.lua in the stdlib project, but it (the whole thing, maybe not
this file in particular) depends on lrexlib (oh, here is our regex
question back). And lrexlib includes a C library. So, this is a no-go
unless the LuaTeX devs decide to include it.

More interesting may be this (surprisingly small) this "POSIX-style" (I
didn't event know that POSIX said anything about command-line options)
implementation of getopt:

http://lua-users.org/wiki/AlternativeGetOpt

I'll probably have a serious look at it soon, since it looks quite ok to
me (I really don't think we need something as big as Perl's
Getopt::Long, do we?)

> Also, the error message has a typo:
> texdoc error: unknow option: -iw
> 
> That should be "unknown".

Fixed, thanks.

Manuel.


More information about the texdoc mailing list