From 743100feabc5eba36160b6e5e73f8c189a23d212 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 24 Nov 2020 09:58:33 +0100 Subject: [PATCH] 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. --- src/nano.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/nano.c b/src/nano.c index eae78688..6febe2c6 100644 --- a/src/nano.c +++ b/src/nano.c @@ -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