Initialize the flags earlier and use VSH_EXCLUSIVE_OPTIONS_VAR to
declare the conflicting options as exclusive.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
tools/vsh.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/tools/vsh.c b/tools/vsh.c
index f44db5d56d..009c93254c 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -3153,20 +3153,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;
--
2.31.1