]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
setarch: disallow unknown command line options
authorSami Kerola <kerolasa@iki.fi>
Sat, 16 Jun 2012 20:59:47 +0000 (22:59 +0200)
committerSami Kerola <kerolasa@iki.fi>
Sun, 17 Jun 2012 15:59:59 +0000 (17:59 +0200)
Exit with instruction to run --help if unknown option is encountered.
Before the following example printed error, but resulted to an attempt
to run argument.

$ x86_64 -x ls

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/setarch.c

index a0c6ea81fbb1f7d72d5fe8357ab3dd56f2415fdb..f2315a660ccd26e0dd332657095d8832e23e99d3 100644 (file)
@@ -122,7 +122,10 @@ show_help(void)
 static void __attribute__((__noreturn__))
 show_usage(const char *s)
 {
-  errx(EXIT_FAILURE, _("%s\nTry `%s --help' for more information."), s, program_invocation_short_name);
+  if (s)
+    errx(EXIT_FAILURE, _("%s\nTry `%s --help' for more information."), s, program_invocation_short_name);
+  else
+    errx(EXIT_FAILURE, _("Try `%s --help' for more information."), program_invocation_short_name);
 }
 
 static void __attribute__((__noreturn__))
@@ -325,6 +328,8 @@ int main(int argc, char *argv[])
     case OPT_UNAME26:
        turn_on(UNAME26, options);
        break;
+    default:
+        show_usage(NULL);
     }
   }