options: do not spew out the help text when an option is not recognized

When getopt() does not recognize an option, it returns '?', which means
that '-?' cannot be used as a valid option because any invalid option
would be treated the same way as '-?'.

Spewing out the full help text drowns the "invalid option" message at
the beginning.

This fixes https://savannah.gnu.org/bugs/?59530.

Bug existed since version 5.3, commit 5bd92d4c.
This commit is contained in:
Benno Schulenberg 2020-11-24 09:58:33 +01:00
parent d3d2d324d2
commit 743100feab
1 changed files with 1 additions and 2 deletions

View File

@ -1848,7 +1848,7 @@ int main(int argc, char **argv)
SET(RESTRICTED);
while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z"
"abcdef:ghijklmno:pqr:s:tuvwxyz$?%!", long_options, NULL)) != -1) {
"abcdef:ghijklmno:pqr:s:tuvwxyz$%!", long_options, NULL)) != -1) {
switch (optchr) {
#ifndef NANO_TINY
case 'A':
@ -2001,7 +2001,6 @@ int main(int argc, char **argv)
break;
#endif
case 'h':
case '?':
usage();
exit(0);
#ifndef NANO_TINY