From: Peter Krempa Date: Tue, 5 Mar 2024 15:17:21 +0000 (+0100) Subject: vsh: Require that positional non-argv arguments are required X-Git-Tag: v10.2.0-rc1~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a45522016630b0e1f4ff1efafdcdcb002e44b4b1;p=thirdparty%2Flibvirt.git vsh: Require that positional non-argv arguments are required This is logically enforced by existing checks, thus we can formalize it. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/tools/vsh.c b/tools/vsh.c index 33a9dcdfe8..ef6451f70e 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -329,6 +329,13 @@ vshCmddefCheckInternals(vshControl *ctl, } } + /* require that positional non-argv options are required */ + if (opt->positional && !opt->required && opt->type != VSH_OT_ARGV) { + vshError(ctl, "positional argument '%s' of command '%s' must be required", + opt->name, cmd->name); + return -1; + } + switch (opt->type) { case VSH_OT_NONE: vshError(ctl, "invalid type 'NONE' of option '%s' of command '%s'",