]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virsh: Treat any command name starting with # as comment
authorEric Blake <eblake@redhat.com>
Fri, 22 Mar 2019 19:02:39 +0000 (14:02 -0500)
committerEric Blake <eblake@redhat.com>
Mon, 25 Mar 2019 14:01:53 +0000 (09:01 -0500)
commit4e650259f92a72e351e4e1d4da109530042fb133
treec5d80dae765627be3077c16bdba6adcb372a973a
parent834f64ca4777f9fc20e0bed5e6cb7b59a76366fd
virsh: Treat any command name starting with # as comment

As the previous commit mentioned, argv mode (such as when you feed
virsh via stdin with <<\EOF instead of via a single shell argument)
didn't permit comments. Do this by treating any command name token
that starts with # as a comment which silently eats all remaining
arguments to the next newline or semicolon.

Note that batch mode recognizes unquoted # at the start of any word as
a command as part of the tokenizer, while this patch only treats # at
the start of the command word as a comment (any other # remaining by
the time vshCommandParse() is processing things was already quoted
during the tokenzier, and as such was probably intended as the actual
argument to the command word earlier in the line).

Now I can do something like:

$ virsh -c test:///default <<EOF
  # setup
  snapshot-create-as test s1
  snapshot-create-as test s2
  # check
  snapshot-list test --name
EOF

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
tests/virshtest.c
tools/virsh.pod
tools/virt-admin.pod
tools/vsh.c