command line options

Doug Gwyn gwyn at brl-smoke.ARPA
Sun Apr 10 09:17:55 AEST 1988


In article <48917 at sun.uucp> guy at 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.



More information about the Comp.unix.wizards mailing list