Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!decwrl!decvax!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: getopt Message-ID: <13730@haddock.ima.isc.com> Date: 16 Jun 89 02:29:01 GMT References: <782@crdgw1.crd.ge.com> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 27 In article <782@crdgw1.crd.ge.com> davidsen@crdos1.UUCP (bill davidsen) writes: >I have a program which needs an option which may have either a default >value or a specific value. ie. "-c" or "-c4" would be typical. I would >like to use getopt to read the values. This doesn't fit the Official Arg Passing Style, so even if you use a hook a kludge into getopt(), it isn't guaranteed to always work. > In the meantime, I took a P.D. version and added another option >qualifier, #, indicating an optional numeric argument. Why restrict it to numeric? I use optional non-numeric arguments all the time. If you're going to add the optional-argument hack, you might as well let it return (in optarg) whatever string immediately followed the keyletter, including the empty string in the case of "-c". (No reason for it ever to return NULL; that would make an unnecessary special case.) >Since the character # could be an option in some software, my new version is >not a superset. "-#" is a not uncommon debugging option. I think ";" is a better choice, since it does half of what ":" does%, and because I don't know of any code that uses "-;" as an option. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint ________ % This pun works only if you pronounce them as "semicolon" and "colon".