Question about GETOPT(3)

Peter da Silva peter at ficc.uu.net
Sat Dec 2 03:45:02 AEST 1989


In article <1143 at cirrusl.UUCP> dhesi%cirrusl at 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 <peter at ficc.uu.net> <peter at sugar.lonestar.org>.
 'U`  --------------  +1 713 274 5180.
"The basic notion underlying USENET is the flame."
	-- Chuq Von Rospach, chuq at Apple.COM 



More information about the Comp.unix.wizards mailing list