From ed8d2938f36c7094ec3ba1dca821b5ded02ba1a5 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 30 Oct 2011 14:45:14 +0100 Subject: switch_root: align with howto-usage-function.txt Signed-off-by: Sami Kerola --- sys-utils/switch_root.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'sys-utils/switch_root.c') diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c index f86b8c697..7c5639682 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); -- cgit v1.2.3-55-g7522