[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU standards: What should happen with illegal option?
From: |
Alfred M. Szmidt |
Subject: |
Re: GNU standards: What should happen with illegal option? |
Date: |
Thu, 22 Jun 2017 04:34:25 -0400 |
The GNU standard for --version and --help says the program should
write to standard output and exit with success. Cf.,
https://www.gnu.org/prep/standards/html_node/_002d_002dhelp.html#g_t_002d_002dhelp
Note that --version and --help are not error messages.
What happens with an illegal option that the program rejects and
exits?
Sometimes it makes sense for an illegal option to just cause a
warning, and sometimes it makes more sense to immediately exit the
program if an illegal option is seen.
Does the message get written to standard output or standard
error?
Standard error in the general case, think of what the user would like
to see if the program never prints output (e.g. piping everything to
/dev/null) when something bad or unexpected is happening.
Should the program exit with an error? (I'm fairly certain it
should exit with an error, but I can't tell where the message should
be printed).
It might continue, depending on the nature of the "error". An error
in the general case is the immediate abortion of a program, but there
are other types of "errors" -- for example if the rm command cannot
delete a file, that is also an error but it would be quite annoying if
it aborted directly if it couldn't remove a file.
If the information could be added to
https://www.gnu.org/prep/standards/html_node/Command_002dLine-Interfaces.html,
then it would be greatly appreciated.
Would you like to suggest a updated text for the GCS?