Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Jun 1999 11:32:18 +0200
From:      Martin Cracauer <cracauer@cons.org>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        hm@hcs.de, imp@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-committers@FreeBSD.ORG
Subject:   Re: cvs commit: src/usr.sbin/i4b/isdnd main.c src/usr.sbin/i4b/isdndebug         main.c src/usr.sbin/i4b/isdndecode main.c src/usr.s
Message-ID:  <19990625113218.A67007@cons.org>
In-Reply-To: <owner-cvs-committersATFreeBSD.ORG--199906240726.RAA29454@godzilla.zeta.org.au>; from Bruce Evans on Fri, Jun 25, 1999 at 02:33:57AM %2B0200
References:  <owner-cvs-committersATFreeBSD.ORG--199906240726.RAA29454@godzilla.zeta.org.au>

next in thread | previous in thread | raw e-mail | index | archive | help
In <owner-cvs-committersATFreeBSD.ORG--199906240726.RAA29454@godzilla.zeta.org.au>, Bruce Evans wrote: 
> >>   	o getopt returns '?' for characters it doesn't know about, so
> >>   	  don't include them in the getopt options string.
> >
> >Including '?' in the getopt options string is intentional, because - last
> >time i checked - using "programname -?" produces an output, where getopt
> >says that "-?" is an invalid option. This is IMHO false in that "-?" is
> >a valid option to display the usage string(s).
> 
> "-?" is an invalid option that can be (ab)used to display the usage
> message.  It is clearly invalid for the i4b programs because none of the
> i4b man pages document it :-).  Documenting it in all man pages wouldn't
> be useful.

I don't think -? should be used on purpose for displaying a usage
message.

For starters, I think the option that explicitly requests the usage
message should cause the tool to exit with zero/true, because it
wasn't an error. That is hard to do when just falling through
getopt(3).

Also, '?' is a shell metacharacter. 

For starters, some shells refuse commandlines with metachars they
cannot expand. csh variants will not call `tool -?` if no file
matching -? exists.

Also, you may get into trouble when matches are found.

If your current working directory happens to have files "-f" and "-r",
`something -?` will turn into `something -f -r`. 

If you are in a public writeable directory, this theoretically makes
it controlable by other people. Most fun if people symlink some of
your files to names matching -? and maybe also touch '--'.

Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@bik-gmbh.de> http://www.bik-gmbh.de/~cracauer/
"Where do you want to do today?" Hard to tell running your calendar 
 program on a junk operating system, eh?


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990625113218.A67007>