From owner-cvs-all Fri Jun 25 2:33:51 1999 Delivered-To: cvs-all@freebsd.org Received: from grisu.bik-gmbh.de (grisu.bik-gmbh.de [194.233.237.82]) by hub.freebsd.org (Postfix) with ESMTP id 2DF15155E8; Fri, 25 Jun 1999 02:33:44 -0700 (PDT) (envelope-from cracauer@counter.bik-gmbh.de) Received: from counter.bik-gmbh.de (counter.bik-gmbh.de [194.233.237.131]) by grisu.bik-gmbh.de (8.8.8/8.6.9) with ESMTP id LAA28503; Fri, 25 Jun 1999 11:33:39 +0200 (MEST) Received: (from cracauer@localhost) by counter.bik-gmbh.de (8.9.3/8.8.8) id LAA67808; Fri, 25 Jun 1999 11:32:18 +0200 (CEST) (envelope-from cracauer) Date: Fri, 25 Jun 1999 11:32:18 +0200 From: Martin Cracauer To: Bruce Evans 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> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.4i In-Reply-To: ; from Bruce Evans on Fri, Jun 25, 1999 at 02:33:57AM +0200 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk In , 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 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