[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 1/6] qemu-img: show help for invalid global options
From: |
Max Reitz |
Subject: |
[Qemu-block] [PULL 1/6] qemu-img: show help for invalid global options |
Date: |
Mon, 27 Mar 2017 17:52:29 +0200 |
From: Stefan Hajnoczi <address@hidden>
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 <address@hidden>
Message-id: address@hidden
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
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
- [Qemu-block] [PULL 0/6] Block patches for rc2, Max Reitz, 2017/03/27
- [Qemu-block] [PULL 1/6] qemu-img: show help for invalid global options,
Max Reitz <=
- [Qemu-block] [PULL 2/6] qemu-img: fix switch indentation in img_amend(), Max Reitz, 2017/03/27
- [Qemu-block] [PULL 4/6] nbd-client: fix handling of hungup connections, Max Reitz, 2017/03/27
- [Qemu-block] [PULL 3/6] qemu-img: print short help on getopt failure, Max Reitz, 2017/03/27
- [Qemu-block] [PULL 5/6] file-posix: Make bdrv_flush() failure permanent without O_DIRECT, Max Reitz, 2017/03/27
- [Qemu-block] [PULL 6/6] block/file-posix.c: Fix unused variable warning on OpenBSD, Max Reitz, 2017/03/27
- Re: [Qemu-block] [PULL 0/6] Block patches for rc2, Peter Maydell, 2017/03/27