Red Hat Bugzilla – Bug 817244
Issues about virsh -h usage
Last modified: 2013-02-21 02:12:35 EST
Description of problem:
Some issues about virsh -h usage
Version-Release number of selected component (if applicable):
Steps to Reproduce:
Ignore all other arguments, and behave as if the help command were
Test with the following, found -h does not ignore all other arguments. If it is not, I think the doc should be improved.
# virsh -h -v -V
# virsh -h -V -v
Virsh command line tool of libvirt 0.9.10
See web site at http://libvirt.org/
Compiled with support for:
Hypervisors: QEmu/KVM LXC ESX Test
Networking: Remote Daemon Network Bridging Netcf Nwfilter VirtualPort
Storage: Dir Disk Filesystem SCSI Multipath iSCSI LVM
Miscellaneous: SELinux Secrets Debug DTrace Readline
doc should be improved.
Also the following result would be confused:
# virsh -l -h
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
Actually here it think -h is a log file name and output this result; not the -h (help) argument to ignore other options and show the help page, which may be the users' original thought.
For comment 0: this should be easy to fix, since the parser currently treats -h as setting a flag that only gets checked after all other options are parsed, while -v and -V exit immediately without parsing the rest of the options. I'll propose a patch upstream.
For comment 1, the behavior is intentional and will not be changed (since it is provided by the getopt_long() function of glibc); -l always takes an argument, even if that argument looks like another option. This is no different from any other program where options take an argument.
Upstream patch proposed
Will be fixed for 6.4 when the rebase picks this up:
Author: Eric Blake <firstname.lastname@example.org>
Date: Mon Apr 30 14:19:11 2012 -0600
virsh: make -h always give help
https://bugzilla.redhat.com/show_bug.cgi?id=817244 mentions that
unlike most other tools, where --help or --version prevent all
further parsing of all later options, virsh was strange in that
--version stopped parsing but --help tried to plow on to the end.
There was no rationale for this original implementation (since
2005!), so I think we can safely conform to common usage patterns.
* tools/virsh.c (main): Drop useless 'help' variable.
Test with libvirt-0.9.13-3.el6.x86_64, bug verified.
When give -h option, all the other arguments will be ignored.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.