Xref: utzoo comp.unix.wizards:19561 comp.unix.questions:18104 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!wuarchive!texbell!sugar!ficc!peter From: peter@ficc.uu.net (Peter da Silva) Newsgroups: comp.unix.wizards,comp.unix.questions Subject: Re: Question about GETOPT(3) Message-ID: <7179@ficc.uu.net> Date: 1 Dec 89 16:45:02 GMT References: <7043@ficc.uu.net> <110@amix.commodore.com> <7077@ficc.uu.net> <118@amix.commodore.com> <1143@cirrusl.UUCP> Reply-To: peter@ficc.uu.net (Peter da Silva) Organization: Xenix Support, FICC Lines: 35 In article <1143@cirrusl.UUCP> dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) writes: > The existence of getopt allows C programs to accept arguments in a > consistent way across many OSes, not just UNIX. Unfortunately, it means that C programs are *inconsistent* with the command line interface of most operating systems. In the latest UNIX Review, Eric Allman describes a better way. It's called "parseargs", and uses a table to describe the command line arguments. This permits the use of multi- character arguments in operating systems where this is the standard, and generates usage and error messages directly. If a program (let's call it foo) uses it, then it could be called as: foo -[abcdef] foofile [file]... foo /{add,block,create,delete,edit,find} foofile [file[,file]...] foo /[abcdef] foofile [file]... foo foofile {add,block,create,delete,edit,find} [file]... foo foofile/{AD,BL,CR,DL,ED,FD}[=file[,file]...] Depending on the operating system it's running under. Not only that, but it's easier to use than getopt: main(ac, av) int ac; char **av; { parseargs(argument_descriptor_table, av); ... } -- `-_-' Peter da Silva . 'U` -------------- +1 713 274 5180. "The basic notion underlying USENET is the flame." -- Chuq Von Rospach, chuq@Apple.COM