Always exit with failure in case of option parsing errors
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
f2a7eea311
commit
1cecfead43
23
src/args.c
23
src/args.c
@ -398,7 +398,7 @@ cleanup:
|
|||||||
/*
|
/*
|
||||||
* Parse the command-line arguments and call the appropriate
|
* Parse the command-line arguments and call the appropriate
|
||||||
* routines to handle those arguments. Also initialize the data paths.
|
* routines to handle those arguments. Also initialize the data paths.
|
||||||
* Returns the non-interactive value.
|
* Exit here in case of errors else return the non-interactive value.
|
||||||
*/
|
*/
|
||||||
int parse_args(int argc, char **argv)
|
int parse_args(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -515,6 +515,10 @@ int parse_args(int argc, char **argv)
|
|||||||
case 'c':
|
case 'c':
|
||||||
cfile = optarg;
|
cfile = optarg;
|
||||||
break;
|
break;
|
||||||
|
case '?':
|
||||||
|
usage();
|
||||||
|
usage_try();
|
||||||
|
exit(EXIT_FAILURE); \
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
io_init(cfile, datadir, confdir);
|
io_init(cfile, datadir, confdir);
|
||||||
@ -557,7 +561,7 @@ int parse_args(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
help_arg();
|
help_arg();
|
||||||
goto cleanup;
|
exit(EXIT_SUCCESS);
|
||||||
case 'g':
|
case 'g':
|
||||||
gc = 1;
|
gc = 1;
|
||||||
break;
|
break;
|
||||||
@ -615,7 +619,7 @@ int parse_args(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
version_arg();
|
version_arg();
|
||||||
goto cleanup;
|
exit(EXIT_SUCCESS);
|
||||||
case 'x':
|
case 'x':
|
||||||
export = 1;
|
export = 1;
|
||||||
if (optarg) {
|
if (optarg) {
|
||||||
@ -860,10 +864,6 @@ int parse_args(int argc, char **argv)
|
|||||||
'\0';
|
'\0';
|
||||||
cmd_line = 1;
|
cmd_line = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
usage();
|
|
||||||
usage_try();
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -876,12 +876,8 @@ int parse_args(int argc, char **argv)
|
|||||||
(format_opt && !(grep + query + dump_imported)) ||
|
(format_opt && !(grep + query + dump_imported)) ||
|
||||||
(query_range && !query) ||
|
(query_range && !query) ||
|
||||||
(purge && !filter.invert)
|
(purge && !filter.invert)
|
||||||
) {
|
)
|
||||||
ERROR_MSG(_("invalid argument combination"));
|
EXIT(_("invalid argument combination"));
|
||||||
usage();
|
|
||||||
usage_try();
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
EXIT_IF(to >= 0 && range, _("cannot specify a range and an end date"));
|
EXIT_IF(to >= 0 && range, _("cannot specify a range and an end date"));
|
||||||
if (from == -1)
|
if (from == -1)
|
||||||
@ -984,7 +980,6 @@ int parse_args(int argc, char **argv)
|
|||||||
non_interactive = 0;
|
non_interactive = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
|
||||||
/* Free filter parameters. */
|
/* Free filter parameters. */
|
||||||
if (filter.regex)
|
if (filter.regex)
|
||||||
regfree(filter.regex);
|
regfree(filter.regex);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user