From 904b6066f67c49aa75bcf236c84e2bf977a2c531 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 8 Dec 2016 01:44:18 -0800 Subject: [PATCH] compel: error out on unknown opt or missing arg getopt_long() prints an error message and returns '?' in cases - an unknown option is given - a required option argument is missing In such cases, we need to show usage and exit with an error. Signed-off-by: Kir Kolyshkin Signed-off-by: Pavel Emelyanov Signed-off-by: Andrei Vagin --- compel/src/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compel/src/main.c b/compel/src/main.c index a2e9a56ff..7fa4d7c28 100644 --- a/compel/src/main.c +++ b/compel/src/main.c @@ -201,7 +201,9 @@ int main(int argc, char *argv[]) COMPEL_SO_VERSION_SUBLEVEL); exit(0); break; - default: + default: // '?' + // error message already printed by getopt_long() + return usage(1); break; } }