]> git.wh0rd.org Git - nano.git/commitdiff
Not blurting out the full help text when command line contains some mistake.
authorBenno Schulenberg <bensberg@justemail.net>
Sun, 27 Apr 2014 12:13:26 +0000 (12:13 +0000)
committerBenno Schulenberg <bensberg@justemail.net>
Sun, 27 Apr 2014 12:13:26 +0000 (12:13 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4820 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/nano.c

index 2e2742e4ed6f0744dc87a25ccf73161243b8ee78..e7af9ad6f43280eead4ed646e1ece9e554af7e01 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-04-27  Benno Schulenberg  <bensberg@justemail.net>
+       * src/nano.c (usage, main): Don't blurt out the full help text
+       but just a hint when the command line contains some mistake, to
+       avoid drowning out the error message.
+
 2014-04-27  Mark Majeres  <mark@engine12.com>
        * src/rcfile.c (parse_include): Plug two tiny memory leaks.
 
index 03c9dcf5c8d635c5d9fab4fb598646b2ca00b5f7..9eba7ad0eef527ef12657752e2fd8a53f1aab0a0 100644 (file)
@@ -837,7 +837,6 @@ void usage(void)
        _("Option\t\tMeaning\n")
 #endif
        );
-    print_opt("-h, -?", "--help", N_("Show this message"));
     print_opt(_("+LINE,COLUMN"), "",
        N_("Start at line LINE, column COLUMN"));
 #ifndef NANO_TINY
@@ -906,6 +905,7 @@ void usage(void)
     print_opt("-d", "--rebinddelete",
        N_("Fix Backspace/Delete confusion problem"));
 #ifndef NANO_TINY
+    print_opt("-h", "--help", N_("Show this help text"));
     print_opt("-i", "--autoindent",
        N_("Automatically indent new lines"));
     print_opt("-k", "--cut", N_("Cut from cursor to end of line"));
@@ -951,8 +951,6 @@ void usage(void)
     /* This is a special case. */
     print_opt("-a, -b, -e,", "", NULL);
     print_opt("-f, -g, -j", "", N_("(ignored, for Pico compatibility)"));
-
-    exit(0);
 }
 
 /* Display the current version of nano, the date and time it was
@@ -2202,11 +2200,11 @@ int main(int argc, char **argv)
     while ((optchr =
 #ifdef HAVE_GETOPT_LONG
        getopt_long(argc, argv,
-               "h?ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefgijklmno:pqr:s:tuvwxz$",
+               "ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$",
                long_options, NULL)
 #else
        getopt(argc, argv,
-               "h?ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefgijklmno:pqr:s:tuvwxz$")
+               "ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$")
 #endif
                ) != -1) {
        switch (optchr) {
@@ -2393,8 +2391,12 @@ int main(int argc, char **argv)
                SET(SOFTWRAP);
                break;
 #endif
-           default:
+           case 'h':
                usage();
+               exit(0);
+           default:
+               printf(_("Type '%s -h' for a list of available options.\n"), argv[0]);
+               exit(1);
        }
     }