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

Zhang Xiaohe zhangxh at cn.fujitsu.com
Fri Mar 22 03:18:48 UTC 2013


于 2013年03月22日 10:17, Eric Blake 写道:
> On 03/21/2013 07:33 PM, Zhang Xiaohe wrote:
>> 于 2013年03月21日 21:08, Eric Blake 写道:
>>> On 03/21/2013 04:20 AM, Daniel P. Berrange wrote:
>>>
>>> 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.
>>>
>> This seems better than just expanding $HOME, i will try this wordexp().
>> One question, is variable can be accepted in the position of command
>> and option? That is, is this form
>> virsh # $VAR --$OPT=~/rpmbuild
>> could be valid?
>
> wordexp() is not portable to mingw, and not provided by gnulib.  If you
> try to use wordexp(), you will basically be re-writing a big chunk of
> /bin/sh.  At this point, I'm not sure it's worth the complexity.
> Interactive virsh does not need to be a full-blown shell.  From the
> command line, you already have the shell parsing things before handing
> it to virsh.
>
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
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" ?




More information about the libvir-list mailing list