From: Sami Kerola Date: Sun, 30 Oct 2011 13:45:14 +0000 (+0100) Subject: switch_root: align with howto-usage-function.txt X-Git-Tag: v2.21-rc1~194^2~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ed8d2938f36c7094ec3ba1dca821b5ded02ba1a5;p=thirdparty%2Futil-linux.git switch_root: align with howto-usage-function.txt Signed-off-by: Sami Kerola --- diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c index f86b8c697a..7c56396820 100644 --- a/sys-utils/switch_root.c +++ b/sys-utils/switch_root.c @@ -32,7 +32,9 @@ #include #include #include + #include "c.h" +#include "nls.h" #ifndef MS_MOVE #define MS_MOVE 8192 @@ -170,18 +172,17 @@ static int switchroot(const char *newroot) return 0; } -static void usage(FILE *output) +static void __attribute__((__noreturn__)) usage(FILE *output) { - fprintf(output, "usage: %s \n", - program_invocation_short_name); - exit(output == stderr ? EXIT_FAILURE : EXIT_SUCCESS); -} + fputs(USAGE_HEADER, output); + fprintf(output, " %s [options] \n", + program_invocation_short_name); + fputs(USAGE_OPTIONS, output); + fputs(USAGE_HELP, output); + fputs(USAGE_VERSION, output); + fprintf(output, USAGE_MAN_TAIL("switch_root(8)")); -static void version(void) -{ - fprintf(stdout, "%s from %s\n", program_invocation_short_name, - PACKAGE_STRING); - exit(EXIT_SUCCESS); + exit(output == stderr ? EXIT_FAILURE : EXIT_SUCCESS); } int main(int argc, char *argv[]) @@ -190,8 +191,10 @@ int main(int argc, char *argv[]) if (argv[1] && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h"))) usage(stdout); - if (argv[1] && (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-V"))) - version(); + if (argv[1] && (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-V"))) { + printf(UTIL_LINUX_VERSION); + return EXIT_SUCCESS; + } if (argc < 3) usage(stderr);