[libvirt] libvirt-guest.sh bug fixes

Eric Blake eblake at redhat.com
Mon Oct 10 18:43:36 UTC 2016


On 10/10/2016 11:48 AM, Stefan Bader wrote:

>> I did not hear about that before. But revisiting things again I think what
>> happened is that the Xen patch which I had done before (but at that time forgot
>> to submit upstream) was adding quotes there because without, the grep does not
>> work. Back then I did not realize this broke the shutdown as that also had
>> quotes around the list. All the other users of the list are ok because they wrap
>> the processing into for ... loops and for those newline or space does not matter.
> 
> I think the surprising part is that the calls to virsh like:
> 
>   list=$(virsh ... list)
> 
> seem to retain the newline seperator despite having no quotes. Only when using
> echo with the unquoted variable seems to do that. That is with dash as sh at least.

That's true for ALL shells.  Word splitting does NOT happen during
variable assignment.  list=$() is _strictly_ equivalent to list="$()",
no matter the shell.

It's just that there are so many other places where $() and "$()" behave
differently that it's (usually) a good habit to always use "", rather
than learning the rules on when you NEED them, vs. telling the special
cases when you DON'T want them apart from the cases where they are optional.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161010/52b3da1e/attachment-0001.sig>


More information about the libvir-list mailing list