qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-img: show help for invalid global options
@ 2017-03-13  5:11 Stefan Hajnoczi
  2017-03-13 13:17 ` Eric Blake
  2017-03-16  2:07 ` Max Reitz
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2017-03-13  5:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi

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>
---
 qemu-img.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qemu-img.c b/qemu-img.c
index 98b836b..ce293a4 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.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-img: show help for invalid global options
  2017-03-13  5:11 [Qemu-devel] [PATCH] qemu-img: show help for invalid global options Stefan Hajnoczi
@ 2017-03-13 13:17 ` Eric Blake
  2017-03-16  2:07 ` Max Reitz
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Blake @ 2017-03-13 13:17 UTC (permalink / raw)
  To: Stefan Hajnoczi, qemu-devel; +Cc: Kevin Wolf

[-- Attachment #1: Type: text/plain, Size: 1161 bytes --]

On 03/13/2017 12:11 AM, Stefan Hajnoczi wrote:
> 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>
> ---
>  qemu-img.c | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/qemu-img.c b/qemu-img.c
> index 98b836b..ce293a4 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':
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-img: show help for invalid global options
  2017-03-13  5:11 [Qemu-devel] [PATCH] qemu-img: show help for invalid global options Stefan Hajnoczi
  2017-03-13 13:17 ` Eric Blake
@ 2017-03-16  2:07 ` Max Reitz
  2017-03-17  9:45   ` Stefan Hajnoczi
  1 sibling, 1 reply; 4+ messages in thread
From: Max Reitz @ 2017-03-16  2:07 UTC (permalink / raw)
  To: Stefan Hajnoczi, qemu-devel; +Cc: Kevin Wolf

[-- Attachment #1: Type: text/plain, Size: 865 bytes --]

On 13.03.2017 06:11, Stefan Hajnoczi wrote:
> 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>
> ---
>  qemu-img.c | 1 +
>  1 file changed, 1 insertion(+)

Well, now you get blown away by a wall of text and spotting what went
wrong is actually not quite simple. Maybe we should follow the way of
the coreutils, that is:

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

?

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-img: show help for invalid global options
  2017-03-16  2:07 ` Max Reitz
@ 2017-03-17  9:45   ` Stefan Hajnoczi
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2017-03-17  9:45 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-devel, Kevin Wolf

[-- Attachment #1: Type: text/plain, Size: 1029 bytes --]

On Thu, Mar 16, 2017 at 03:07:29AM +0100, Max Reitz wrote:
> On 13.03.2017 06:11, Stefan Hajnoczi wrote:
> > 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>
> > ---
> >  qemu-img.c | 1 +
> >  1 file changed, 1 insertion(+)
> 
> Well, now you get blown away by a wall of text and spotting what went
> wrong is actually not quite simple. Maybe we should follow the way of
> the coreutils, that is:
> 
> qemu-img: unrecognized option '--foo'
> Try 'qemu-img --help' for more information.
> 
> ?

Sure, I'll add another patch to improve that.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-17  9:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-13  5:11 [Qemu-devel] [PATCH] qemu-img: show help for invalid global options Stefan Hajnoczi
2017-03-13 13:17 ` Eric Blake
2017-03-16  2:07 ` Max Reitz
2017-03-17  9:45   ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).