The question of why some commands rely on
manpages whereas others rely on something like the
--help flag for providing command usage reference is not new. There is usually a difference in scope between documentation for a command and a command usage synopsis. The latter is often a subset of the former. But even when most commands and utilities have manpages for instance, there exists differences in their formatting of the synopsis section which have very practical implications when trying to extract such information. In other cases one might find clues with the
strings utility when a command has seemingly no documentation.
I was interested with the commands I have on this QNX platform and discovered the
use command1 to display usage information. As explained in
usemsg, the framework involves setting a standard usage record in the utilities source and once compiled this can be accessed with the
use command and you can also wrap the native functionality etc. It is quite convenient as I could simply do
use -d dir >>file
/proc/boot to extract all the usage for all the commands on the system basically.
So I then briefly looked at the source for GNU coreutils ls and FreeBSD ls to see if they did something like that and the former puts usage information in some usage named function(for
--help I guess) while the latter doesn't seem to put it anywhere at all(?).
- Is this sort of solution(
use) typical of what you find with commercial Unix to present command usage reference interactively?
- Does POSIX/SUS recommend or suggest anything about presenting/implementing command usage reference in commands(as opposed to specifying notation for shell utilities)?
use Print a usage message (QNX Neutrino) Syntax: use [-aeis] [-d directory] [-f filelist] files Options: -a Extract all usage information from the load module in its source form, suitable for piping into usemsg. -d directory Recursively display information for all files under directory. -e Include only ELF files. -f filelist Read a list of files, one per line, from the specified filelist file, and display information for each. -i Display build properties about a load module. -s Display the version numbers of the source used in the executable. files One or more executable load modules or shell scripts that contain usage messages.