From: Peter Krempa Date: Wed, 11 Aug 2021 08:36:04 +0000 (+0200) Subject: virsh: cmdEcho: Make '--xml' and '--shell' mutually exclusive X-Git-Tag: v7.7.0-rc1~121 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86de16b3170cb7131222a64fe955861ed2e3a3b4;p=thirdparty%2Flibvirt.git virsh: cmdEcho: Make '--xml' and '--shell' mutually exclusive Initialize the flags earlier and use VSH_EXCLUSIVE_OPTIONS_VAR to declare the conflicting options as exclusive. Signed-off-by: Peter Krempa Reviewed-by: Martin Kletzander Reviewed-by: Ján Tomko --- diff --git a/tools/vsh.c b/tools/vsh.c index e49d2a3863..fc20fb21ee 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -3150,20 +3150,15 @@ const vshCmdInfo info_echo[] = { bool cmdEcho(vshControl *ctl, const vshCmd *cmd) { - bool shell = false; - bool xml = false; - bool err = false; + bool shell = vshCommandOptBool(cmd, "shell"); + bool xml = vshCommandOptBool(cmd, "xml"); + bool err = vshCommandOptBool(cmd, "err"); int count = 0; const vshCmdOpt *opt = NULL; g_autofree char *arg = NULL; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - if (vshCommandOptBool(cmd, "shell")) - shell = true; - if (vshCommandOptBool(cmd, "xml")) - xml = true; - if (vshCommandOptBool(cmd, "err")) - err = true; + VSH_EXCLUSIVE_OPTIONS_VAR(shell, xml); while ((opt = vshCommandOptArgv(ctl, cmd, opt))) { g_autofree char *str = NULL;