Prevent the use of any non-option arguments with -R or -Q (#101).

This commit is contained in:
Andrew Wood
2025-10-21 20:48:44 +01:00
parent 3f1782a573
commit de71cc2389
+11 -1
View File
@@ -1178,7 +1178,17 @@ opts_t opts_parse(unsigned int argc, char **argv)
if (opts->error_skip_block > 0 && 0 == opts->skip_errors)
opts->skip_errors = 1;
/* TODO: error if -Q given and there are any remaining arguments. */
/*
* Don't allow any non-option arguments with -R or -Q.
*/
if ((optind < (int) argc) && ((0 != opts->remote) || (0 != opts->query))) {
/*@-mustfreefresh@ *//* see above */
fprintf(stderr, "%s: %s: %s\n", opts->program_name, 0 != opts->remote ? "-R" : "-Q",
_("files cannot be specified with this option"));
opts_free(opts);
return NULL;
/*@+mustfreefresh@ */
}
/*
* Store remaining command-line arguments.