]> git.proxmox.com Git - mirror_qemu.git/commit
qemu-img: print short help on getopt failure
authorStefan Hajnoczi <stefanha@redhat.com>
Fri, 17 Mar 2017 10:45:41 +0000 (18:45 +0800)
committerMax Reitz <mreitz@redhat.com>
Mon, 27 Mar 2017 14:50:36 +0000 (16:50 +0200)
commitc919297379e9980c2bcc4d2053addbc1fd6d762b
tree505147e6b8b95a68b7c10ded61b5e32e5c83e03f
parentf7077624b036bd70b0b04d6b3f9a7effc80a74a9
qemu-img: print short help on getopt failure

Printing the full help output obscures the error message for an invalid
command-line option or missing argument.

Before this patch:

  $ ./qemu-img --foo
  ...pages of output...

After this patch:

  $ ./qemu-img --foo
  qemu-img: unrecognized option '--foo'
  Try 'qemu-img --help' for more information

This patch adds the getopt ':' character so that it can distinguish
between missing arguments and unrecognized options.  This helps provide
more detailed error messages.

Suggested-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20170317104541.28979-4-stefanha@redhat.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
qemu-img.c