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

Eric Blake eblake at redhat.com
Fri Mar 22 03:43:02 UTC 2013


On 03/21/2013 09:18 PM, Zhang Xiaohe wrote:

> Originally, I think '~' and '$HOME' is most commonly used, so it should
> be acceptable to just expand these.
> But now I'm confused. You said
>> if we're going to do this, go all the way

Expanding just '~' and '$HOME' but nothing else is a disservice to the
user.  If we're going to expand anything, then we should be consistent
and allow for the expansion of all variables.

> and
>> Interactive virsh does not need to be a full-blown shell.
> I'm not sure but are you suggesting that "no need to add this expansion" ?

Expanding everything means re-implementing what the shell does.
wordexp() would be ideal for this, except that wordexp() is not portable
enough.  By the time we end up rewriting enough code to do what
wordexp() already could do, we are adding lots of bloat into virsh to
make it mimic what /bin/sh can already do.

Ergo, I think that this patch idea is not worth it.  If a user wants
shell expansions, they should let the shell do it, when building up the
virsh command line.  That is, instead of trying to do expansions in a
virsh interactive session:

$ virsh
virsh# echo $HOME

you should just let the shell do it beforehand:

$ virsh "echo $HOME"

-- 
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/fc6c722e/attachment-0001.sig>


More information about the libvir-list mailing list