command line options
Doug Gwyn
gwyn at brl-smoke.ARPA
Fri Apr 8 22:10:21 AEST 1988
In article <8040 at elsie.UUCP> ado at elsie.UUCP (Arthur David Olson) writes:
>> > I want some uniform way of getting programs to output their usage messages.
>> Under the existing getopts scheme, typing
>> command -?
>> is guaranteed to get the usage message.
>A problem and a two questions. First, the problem:
> No manual entry for getopts.
"getopts" is a builtin in the SVR3 and later shells; it is also built
into the current BRL version of the SVR2 shell.
I was actually referring to the getopt() library function, since that's
what the ongoing discussion was about. A command that uses getopt()
will branch to the "error case" if you use the ? flag option. The
normal response in the error case is to print a usage message.
>Second, the questions. Is a public-domain implementation of "the existing
>getopts scheme," or at least a public-domain manual page, available?
AT&T placed the getopt() source code, its manual page, the now-obsolete
"getopt" utility, and its manual page into the public domain a few years
ago. You can get this free from the AT&T UNIX System ToolChest, and I
believe it was posted to one of the sources newsgroups.
I typed up a "getopts" shell builtin manual page that I can send you,
if you can't find it in UNIX System V Release 3 documentation.
>is the scheme idiot-proof enough to work when executed in directories with
>files named, for example, "-l"?
If you have reason to believe that your command may have to handle
non-option arguments with names starting with -, then follow the
options with the -- option, which causes getopt() to stop interpreting
arguments as options.
More information about the Comp.unix.wizards
mailing list