All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 1/6] qemu-img: show help for invalid global options
Date: Mon, 27 Mar 2017 17:52:29 +0200	[thread overview]
Message-ID: <20170327155234.10980-2-mreitz@redhat.com> (raw)
In-Reply-To: <20170327155234.10980-1-mreitz@redhat.com>

From: Stefan Hajnoczi <stefanha@redhat.com>

The qemu-img sub-command executes regardless of invalid global options:

  $ qemu-img --foo info test.img
  qemu-img: unrecognized option '--foo'
  image: test.img
  ...

The unrecognized option warning may be missed by the user.  This can
hide incorrect command-lines in scripts and confuse users.

This patch prints the help information and terminates instead of
executing the sub-command.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20170317104541.28979-2-stefanha@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 qemu-img.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qemu-img.c b/qemu-img.c
index 98b836b030..ce293a4710 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -4339,6 +4339,7 @@ int main(int argc, char **argv)
     while ((c = getopt_long(argc, argv, "+hVT:", long_options, NULL)) != -1) {
         switch (c) {
         case 'h':
+        case '?':
             help();
             return 0;
         case 'V':
-- 
2.12.1

  reply	other threads:[~2017-03-27 15:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-27 15:52 [Qemu-devel] [PULL 0/6] Block patches for rc2 Max Reitz
2017-03-27 15:52 ` Max Reitz [this message]
2017-03-27 15:52 ` [Qemu-devel] [PULL 2/6] qemu-img: fix switch indentation in img_amend() Max Reitz
2017-03-27 15:52 ` [Qemu-devel] [PULL 3/6] qemu-img: print short help on getopt failure Max Reitz
2017-03-27 15:52 ` [Qemu-devel] [PULL 4/6] nbd-client: fix handling of hungup connections Max Reitz
2017-03-27 15:52 ` [Qemu-devel] [PULL 5/6] file-posix: Make bdrv_flush() failure permanent without O_DIRECT Max Reitz
2017-03-27 15:52 ` [Qemu-devel] [PULL 6/6] block/file-posix.c: Fix unused variable warning on OpenBSD Max Reitz
2017-03-27 16:34 ` [Qemu-devel] [PULL 0/6] Block patches for rc2 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170327155234.10980-2-mreitz@redhat.com \
    --to=mreitz@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.