From: Karel Zak Date: Tue, 30 Nov 2010 11:46:06 +0000 (+0100) Subject: renice: rewrite usage() X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=296351b0f112c821bffbe8ce7aa35d716251051d;p=util-linux renice: rewrite usage() Signed-off-by: Karel Zak --- diff --git a/sys-utils/renice.c b/sys-utils/renice.c index e45c5aed..4af6f04b 100644 --- a/sys-utils/renice.c +++ b/sys-utils/renice.c @@ -49,16 +49,27 @@ static int donice(int,int,int); -static void usage(int rc) +static int __attribute__((__noreturn__)) usage(FILE *out) { - printf( _("\nUsage:\n" - " renice [-n] priority [-p|--pid] pid [... pid]\n" - " renice [-n] priority -g|--pgrp pgrp [... pgrp]\n" - " renice [-n] priority -u|--user user [... user]\n" - " renice -h | --help\n" - " renice -v | --version\n\n")); - - exit(rc); + fprintf(out, _( + "\nUsage:\n" + " %1$s [-n] [-p] [ ...]\n" + " %1$s [-n] -g [ ...]\n" + " %1$s [-n] -u [ ...]\n"), + program_invocation_short_name); + + fprintf(out, _( + "\nOptions:\n" + " -g, --pgrp interpret as process group ID\n" + " -h, --help print help\n" + " -n, --priority set the nice increment value\n" + " -p, --pid force to be interpreted as process ID\n" + " -u, --user interpret as username or user ID\n" + " -v, --version print version\n")); + + fprintf(out, _("\nFor more information see renice(1).\n")); + + exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS); } /* @@ -83,7 +94,7 @@ main(int argc, char **argv) if (argc == 1) { if (strcmp(*argv, "-h") == 0 || strcmp(*argv, "--help") == 0) - usage(EXIT_SUCCESS); + usage(stdout); if (strcmp(*argv, "-v") == 0 || strcmp(*argv, "--version") == 0) { @@ -93,7 +104,7 @@ main(int argc, char **argv) } if (argc < 2) - usage(EXIT_FAILURE); + usage(stderr); if (strcmp(*argv, "-n") == 0 || strcmp(*argv, "--priority") == 0) { argc--; @@ -102,7 +113,7 @@ main(int argc, char **argv) prio = strtol(*argv, &endptr, 10); if (*endptr) - usage(EXIT_FAILURE); + usage(stderr); argc--; argv++;