mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 12:28:09 +01:00
config: Check 'config get' arity exactly
Require that 'config get' is passed exactly one additional argument, instead of silently ignoring extra arguments. As a side-effect, produce more specific error messages for the 'config' command as a whole.
This commit is contained in:
parent
7bfc4bf501
commit
371f3b12a6
1 changed files with 15 additions and 4 deletions
|
@ -804,15 +804,26 @@ notmuch_config_command (void *ctx, int argc, char *argv[])
|
|||
{
|
||||
argc--; argv++; /* skip subcommand argument */
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf (stderr, "Error: notmuch config requires at least two arguments.\n");
|
||||
if (argc < 1) {
|
||||
fprintf (stderr, "Error: notmuch config requires at least one argument.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strcmp (argv[0], "get") == 0)
|
||||
if (strcmp (argv[0], "get") == 0) {
|
||||
if (argc != 2) {
|
||||
fprintf (stderr, "Error: notmuch config get requires exactly "
|
||||
"one argument.\n");
|
||||
return 1;
|
||||
}
|
||||
return notmuch_config_command_get (ctx, argv[1]);
|
||||
else if (strcmp (argv[0], "set") == 0)
|
||||
} else if (strcmp (argv[0], "set") == 0) {
|
||||
if (argc < 2) {
|
||||
fprintf (stderr, "Error: notmuch config set requires at least "
|
||||
"one argument.\n");
|
||||
return 1;
|
||||
}
|
||||
return notmuch_config_command_set (ctx, argv[1], argc - 2, argv + 2);
|
||||
}
|
||||
|
||||
fprintf (stderr, "Unrecognized argument for notmuch config: %s\n",
|
||||
argv[0]);
|
||||
|
|
Loading…
Reference in a new issue