From 677ec86cef983a106c6e5d175f44b125858c3016 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 19 Dec 2016 13:13:34 +0100 Subject: Use --help suggestion on invalid option The current default is to print all usage() output. This is overkill in many case. Addresses: https://github.com/karelzak/util-linux/issues/338 Signed-off-by: Karel Zak --- schedutils/chrt.c | 7 ++----- schedutils/ionice.c | 2 +- schedutils/taskset.c | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) (limited to 'schedutils') diff --git a/schedutils/chrt.c b/schedutils/chrt.c index 73d1ffa9b..b52aec137 100644 --- a/schedutils/chrt.c +++ b/schedutils/chrt.c @@ -439,8 +439,6 @@ int main(int argc, char **argv) while((c = getopt_long(argc, argv, "+abdD:fiphmoP:T:rRvV", longopts, NULL)) != -1) { - int ret = EXIT_FAILURE; - switch (c) { case 'a': ctl->all_tasks = 1; @@ -496,10 +494,9 @@ int main(int argc, char **argv) printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': - ret = EXIT_SUCCESS; - /* fallthrough */ + show_usage(EXIT_SUCCESS); default: - show_usage(ret); + errtryhelp(EXIT_FAILURE); } } diff --git a/schedutils/ionice.c b/schedutils/ionice.c index 5528afed5..38a6846f9 100644 --- a/schedutils/ionice.c +++ b/schedutils/ionice.c @@ -203,7 +203,7 @@ int main(int argc, char **argv) case 'h': usage(stdout); default: - usage(stderr); + errtryhelp(EXIT_FAILURE); } switch (ioclass) { diff --git a/schedutils/taskset.c b/schedutils/taskset.c index d6b21e45c..199d62566 100644 --- a/schedutils/taskset.c +++ b/schedutils/taskset.c @@ -172,8 +172,7 @@ int main(int argc, char **argv) usage(stdout); break; default: - usage(stderr); - break; + errtryhelp(EXIT_FAILURE); } } -- cgit v1.2.3-55-g7522