From edf1cf0af541cd4ffe5d91d776627e0d70ded184 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 16 Jun 2012 22:59:47 +0200 Subject: 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 --- sys-utils/setarch.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sys-utils/setarch.c') diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c index a0c6ea81f..f2315a660 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); } } -- cgit v1.2.3-55-g7522