Xref: utzoo comp.lang.c:9087 comp.unix.wizards:7669 Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!nrl-cmf!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c,comp.unix.wizards Subject: Re: command line options Message-ID: <7641@brl-smoke.ARPA> Date: 9 Apr 88 23:17:55 GMT References: <2414@zyx.UUCP> <8039@elsie.UUCP> <7628@brl-smoke.ARPA> <143@gsg.UUCP> <7634@brl-smoke.ARPA> <48917@sun.uucp> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 26 In article <48917@sun.uucp> guy@gorodish.Sun.COM (Guy Harris) writes: >In fact, I can't see how it *can* cons up a complete usage message; the best it >can do is tell you what options it expects - it can't tell you that it expects >two file names, a number from 1 to 10, and the air speed of a laden swallow. >While the code to *recognize* '-?' doesn't have to be explicitly added to every >application using "getopt()", the code to respond to it and print a usage >message does. $ ls -? ls: illegal option -- ? usage: ls -RadCxmnlogrtucpFbqisfL [files] The particular usage message produced depends entirely on what the implementor of the application decided was the appropriate response to an illegal option. (This is the "case '?':" section of the code, which should always exist because getopt() returns '?' for any illegal option.) You may think that the "ls" implementor should have provided more help than that. On UNIX, it is generally assumed that you just need to be reminded what the correct syntax is; if you need more help you're expected to use the "man" command to read the on-line manual entry. In other environments it may indeed be appropriate to have a verbose usage message. My point is that there is already the necessary hook for this under the present getopt() scheme; nothing needs to be changed to use it.