]> xenbits.xensource.com Git - libvirt.git/commit
bash-completion: Fix argument passing to $1
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 20 Apr 2021 13:03:16 +0000 (15:03 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 22 Apr 2021 08:14:38 +0000 (10:14 +0200)
commit7657804df7126bc69b9b7a52c710dbad153b6ae4
tree1b2b68afb5ffba15a7f4003b3ea9fdde8c759b48
parentf0e5100f002a0e5ad264f16128fabb285c3afa84
bash-completion: Fix argument passing to $1

Our vsh bash completion string is merely just a wrapper over
virsh/virt-admin complete (cmdComplete) - a hidden command that
uses internal readline completion to generate list of candidates.
But this means that we have to pass some additional arguments to
the helper process: e.g. connection URI and R/O flag.

Candidates are printed on a separate line each (and can contain
space), which means that when bash is reading the helper's output
into an array, it needs to split items on '\n' char - hence the
IFS=$'\n' prefix on the line executing the helper. This was
introduced in b889594a70.

But this introduced a regression - those extra arguments we might
pass are stored in a string and previously were split on a space
character (because $IFS was kept untouched and by default
contains space). But now, after the fix that's no longer the case
and thus virsh/virt-admin sees ' -r -c URI' as one argument.

The solution is to take $IFS out of the picture by storing the
extra arguments in an array instead of string.

Fixes: b889594a7092440dc916e3f43eeeaca2684571ee
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
tools/bash-completion/vsh