5

If I have an application that runs via a shell, is there POSIX documentation that says --help support is required? I would think so, as this seems to be a standard practice among the most popular terminal applications (GNU tools, etc).

I'm mostly curious if I can use the presence or lack of a "--help" option as a litmus test for finding POSIX-compliant/non-compliant commands.

1
  • Longopts were a GNU idea. Since POSIX only specifies getopt and not getopt_long, I'd guess --help is never part of the standard.
    – Cairnarvon
    May 29, 2013 at 17:33

2 Answers 2

6

POSIX doesn't mandate --help: http://pubs.opengroup.org/onlinepubs/009695399/utilities/ls.html

In fact, it seems that POSIX guidelines suggest avoiding options that aren't a single character (though it's not prohibited, just a guideline):

Guideline 3: Each option name should be a single alphanumeric character (the alnum character classification) from the portable character set. The -W (capital-W) option shall be reserved for vendor options.

Multi-digit options should not be allowed.
2
  • 1
    The reason it seems to indicate not using multi-character options is that they are supposed to be parsable by the posix getopt(), which doesn't take multi-character options May 29, 2013 at 17:36
  • 1
    Interesting that -h is not mentioned either.
    – Dave
    May 29, 2013 at 20:33
0

I agree with the existing answer, that --help is not specified by POSIX/SUS.

However, if you are looking for any sort of standardization, --help is included in the GNU Coding Standards.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.