What is the "POSIX-defined format" for command-line error messages? Which standard? What is the "POSIX-defined format" for command-line error messages? Which standard? ruby ruby

What is the "POSIX-defined format" for command-line error messages? Which standard?


IEEE Std 1003.1 it is. See errno.h, Error Numbers. Also known as POSIX.1-2008, and earlier revisions (see wiki for more details on sections, years etc).

Note that systems are likely to have extended set of error numbers and messages associated with them. For example, Linux supports error numbers defined by C99. There could be implementation-specific errors as well. Here is Linux's errno.h for reference.


Since your question is about the getopt() function, presumably, you are looking for the POSIX specification of the getopt() function. The specification for that defers to the getopts utility for the error messages it can produce. The rationale section of the getopts utility describes the format of some error messages in some existing implementations, but does not mandate them.

You should also look at the Utility Conventions specification for the rules that a POSIX utility normally conforms to. (There are deviations from the conventions, normally because of long-established historical precedent. There is, typically, a variation defined which matches the POSIX conventions.)