Not blurting out the full help text when command line contains some mistake.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4820 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2014-04-27 12:13:26 +00:00
parent 20011f4d41
commit 43019189ca
2 changed files with 13 additions and 6 deletions

View File

@ -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> 2014-04-27 Mark Majeres <mark@engine12.com>
* src/rcfile.c (parse_include): Plug two tiny memory leaks. * src/rcfile.c (parse_include): Plug two tiny memory leaks.

View File

@ -837,7 +837,6 @@ void usage(void)
_("Option\t\tMeaning\n") _("Option\t\tMeaning\n")
#endif #endif
); );
print_opt("-h, -?", "--help", N_("Show this message"));
print_opt(_("+LINE,COLUMN"), "", print_opt(_("+LINE,COLUMN"), "",
N_("Start at line LINE, column COLUMN")); N_("Start at line LINE, column COLUMN"));
#ifndef NANO_TINY #ifndef NANO_TINY
@ -906,6 +905,7 @@ void usage(void)
print_opt("-d", "--rebinddelete", print_opt("-d", "--rebinddelete",
N_("Fix Backspace/Delete confusion problem")); N_("Fix Backspace/Delete confusion problem"));
#ifndef NANO_TINY #ifndef NANO_TINY
print_opt("-h", "--help", N_("Show this help text"));
print_opt("-i", "--autoindent", print_opt("-i", "--autoindent",
N_("Automatically indent new lines")); N_("Automatically indent new lines"));
print_opt("-k", "--cut", N_("Cut from cursor to end of line")); print_opt("-k", "--cut", N_("Cut from cursor to end of line"));
@ -951,8 +951,6 @@ void usage(void)
/* This is a special case. */ /* This is a special case. */
print_opt("-a, -b, -e,", "", NULL); print_opt("-a, -b, -e,", "", NULL);
print_opt("-f, -g, -j", "", N_("(ignored, for Pico compatibility)")); print_opt("-f, -g, -j", "", N_("(ignored, for Pico compatibility)"));
exit(0);
} }
/* Display the current version of nano, the date and time it was /* Display the current version of nano, the date and time it was
@ -2202,11 +2200,11 @@ int main(int argc, char **argv)
while ((optchr = while ((optchr =
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
getopt_long(argc, argv, getopt_long(argc, argv,
"h?ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefgijklmno:pqr:s:tuvwxz$", "ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$",
long_options, NULL) long_options, NULL)
#else #else
getopt(argc, argv, getopt(argc, argv,
"h?ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefgijklmno:pqr:s:tuvwxz$") "ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$")
#endif #endif
) != -1) { ) != -1) {
switch (optchr) { switch (optchr) {
@ -2393,8 +2391,12 @@ int main(int argc, char **argv)
SET(SOFTWRAP); SET(SOFTWRAP);
break; break;
#endif #endif
default: case 'h':
usage(); usage();
exit(0);
default:
printf(_("Type '%s -h' for a list of available options.\n"), argv[0]);
exit(1);
} }
} }