From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csWwp-0001S2-3R for qemu-devel@nongnu.org; Mon, 27 Mar 2017 11:52:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csWwo-0006CZ-HX for qemu-devel@nongnu.org; Mon, 27 Mar 2017 11:52:47 -0400 From: Max Reitz Date: Mon, 27 Mar 2017 17:52:29 +0200 Message-Id: <20170327155234.10980-2-mreitz@redhat.com> In-Reply-To: <20170327155234.10980-1-mreitz@redhat.com> References: <20170327155234.10980-1-mreitz@redhat.com> Subject: [Qemu-devel] [PULL 1/6] qemu-img: show help for invalid global options List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Max Reitz , Peter Maydell , Stefan Hajnoczi From: 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 Message-id: 20170317104541.28979-2-stefanha@redhat.com Reviewed-by: Eric Blake Signed-off-by: Max Reitz --- 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