Bug 806793 - [RFE]virsh should support '~' ‘$HOME’ in interactive mode
[RFE]virsh should support '~' ‘$HOME’ in interactive mode
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Libvirt Maintainers
: FutureFeature
Depends On:
  Show dependency treegraph
Reported: 2012-03-26 05:09 EDT by zhpeng
Modified: 2016-04-26 14:13 EDT (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-03-23 17:01:34 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description zhpeng 2012-03-26 05:09:30 EDT
Description of problem:
virsh can't use '~' in interactive mode

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
[root@daisy tmp]# virsh
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # pwd

virsh # attach-device rhel6.3 ../root/interface.xml
Device attached successfully

virsh # detach-device rhel6.3 ../root/interface.xml
Device detached successfully

virsh # attach-device rhel6.3 ~/interface.xml
error: Failed to open file '~/interface.xml': No such file or directory

virsh # save rhel6.3 ~/rhel6.3.save
error: Failed to save domain rhel6.3 to ~/rhel6.3.save
error: Failed to create file '/tmp/~/rhel6.3.save': Operation not permitted

virsh # save win2008 $HOME/win2008.save
error: Failed to save domain win2008 to $HOME/win2008.save
error: Failed to create file '/tmp/$HOME/win2008.save': Operation not permitted

virsh # 
Actual results:
virsh do not support '~' ‘$HOME’

Expected results:
support  '~' ‘$HOME’

Additional info:
This kind of usage is very common and many interactive command support this(like ftp)
Comment 1 zhpeng 2012-03-26 05:19:57 EDT
Some info from Eric:
~ expansion is normally done by the shell, but only in certain positions
on the command line.  It might be worth teaching virsh how to do ~
expansion, since those arguments don't fall under the shell's rules.
~ expansion is just shorthand for $HOME.

no-interactive mode works:

[root@zhpeng ~]# virsh save win2008 $HOME/win2008.save

Domain win2008 saved to /root/win2008.save

[root@zhpeng ~]# virsh save win2008 ~/win2008.save

Domain win2008 saved to /root/win2008.save
Comment 4 Cole Robinson 2016-03-23 17:01:34 EDT
eh, I don't know... virsh is not a real shell, $ variables don't work work, you can't pipe, etc. why make an exception for '~' ? if someone provided a patch for this I'm sure we would take it but it doesn't belong in the bug tracker IMO

Note You need to log in before you can comment on or make changes to this bug.