Date: Fri, 24 Apr 1998 22:32:47 +0800 From: Peter Wemm <peter@netplex.com.au> To: dag-erli@ifi.uio.no (Dag-Erling Coidan =?iso-8859-1?Q?Sm=F8rgrav?= ) Cc: current@FreeBSD.ORG, stable@FreeBSD.ORG Subject: Re: ls Message-ID: <199804241432.WAA14634@spinner.netplex.com.au> In-Reply-To: Your message of "24 Apr 1998 12:44:11 %2B0200." <xzpson38pok.fsf@gjallarhorn.ifi.uio.no>
next in thread | previous in thread | raw e-mail | index | archive | help
Dag-Erling Coidan =?iso-8859-1?Q?Sm=F8rgrav?= wrote: > current's ls now accepts three new options: > > -? Display a short list of options (this was already in the code, but > was left out from the call to getopt) Umm.. getopt() cannot have a ? option. It's what it returns if it doesn't recognize the given arg. while ((c = getopt("abc")) != 1) { switch (c) { case 'a': .. case 'b': .. case 'c': .. case '?': warnx("unknown option '%c' supplied", optopt); usage(); default: warnx("unknown return from getopt()"); ... } } So, "default" is normally a programming error - ie: a character is supplied in the optstring but not handled in the switch statement. "?" is what getopt returns when the user supplies an arg that is not known to getopt at all. I'd suggest removing the '?' from the optstring again.. 'some_cmd -?' will always return '?' from getopt() (by definition), regardless of whether it is listed or not. Cheers, -Peter -- Peter Wemm <peter@netplex.com.au> Netplex Consulting To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199804241432.WAA14634>