From: Sami Kerola Date: Sat, 16 Jun 2012 20:59:47 +0000 (+0200) Subject: setarch: disallow unknown command line options X-Git-Tag: v2.22-rc1~267^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=edf1cf0af541cd4ffe5d91d776627e0d70ded184;p=thirdparty%2Futil-linux.git setarch: disallow unknown command line options 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 --- diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c index a0c6ea81fb..f2315a660c 100644 --- a/sys-utils/setarch.c +++ b/sys-utils/setarch.c @@ -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); } }