[libvirt] [PATCH] Make virsh support '~' and '$HOME' in interactive mode

Eric Blake eblake at redhat.com
Thu Mar 21 13:08:45 UTC 2013


On 03/21/2013 04:20 AM, Daniel P. Berrange wrote:
> On Thu, Mar 21, 2013 at 05:00:58PM +0800, Zhang Xiaohe wrote:
>> This patch makes '~' and '$HOME' can be recognized by virsh in
>> interactive mode. These two variables are replaced with real
>> path.
> 
> If we're going to the trouble of expanding $HOME, then we might
> as well just make it expand arbitrary environment variables
> rather than hardcoding $HOME.

In other words, if we're going to do this, go all the way and use
wordexp() to get shell-like expansion, instead of reinventing it
ourselves.  Except that wordexp() is not portable to mingw, and not
provided in gnulib.

> 
> Also, we'll need a way to escape the special meaning of '~'
> and '$' to get them treated as literal characters instead of
> special characters.

We already have the ability to quote characters, so that we can embed
spaces; our quoting rules are (intentionally) copied on shell rules, so
they would still work with a wordexp() approach.

-- 
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: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130321/2690b8f3/attachment-0001.sig>


More information about the libvir-list mailing list