Path: utzoo!mnetor!uunet!husc6!rutgers!iuvax!pur-ee!uiucdcs!uxc.cso.uiuc.edu!ccvaxa!aglew From: aglew@ccvaxa.UUCP Newsgroups: comp.unix.wizards Subject: Re: Command interfaces Message-ID: <57900006@ccvaxa> Date: 19 Dec 87 18:51:00 GMT References: <432@cresswell.quintus.UUCP> Lines: 43 Nf-ID: #R:cresswell.quintus.UUCP:432:ccvaxa:57900006:000:1242 Nf-From: ccvaxa.UUCP!aglew Dec 19 12:51:00 1987 In article <22179@ucbvax.BERKELEY.EDU> Keith Bostic writes: >In article <57900005@ccvaxa>, aglew@ccvaxa.UUCP writes: >>..> Henry Spencer on getopt() >> Another reason not to use getopt: because it requires information to >> be put in two places. You have to have a string containing your option >> letters, and a case for the actual option. Bad design. > >I am totally lost. You want to explain how you're going to avoid having >"information in two places"? Well, in the days before I came to UNIX (using Whitesmith's on a PDP with RT-11, if I remember correctly), I used to do: main(argc,argv) int argc; char **argv; { for(;*++argv;) { if( !strcmp(*argv,"-flag") ) { Flag = 1; } else if( BinaryFlag(*argv,"binary",&Bflag) ) { /* Set or reset Bflag if -binary or -nobinary was specified */ } else if( OpenFile(&argv,"-f","rw",&fd) ) { } else if( HandleDefaultArguments() ) { /* This and others would handle arguments standard to all my code, such as verbose, debug, etc. */ } else Usage(); } ... } No, it's not UNIX, it doesn't use single letter flags, but I'm not so sure that it wasn't better in promoting a standard interface than getopts.