]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
findfs: add --version & align with howto-usage-function.txt
authorSami Kerola <kerolasa@iki.fi>
Thu, 15 Mar 2012 21:58:09 +0000 (22:58 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 30 Mar 2012 14:48:11 +0000 (16:48 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
misc-utils/findfs.c

index 04651b3a5dde8a1d225adb5c956a8e9048571dce..761c6e91fa8236643442ebceb36d939b389de9fe 100644 (file)
 
 static void __attribute__((__noreturn__)) usage(int rc)
 {
-       const char *p = program_invocation_short_name;
-
-       if (!p)
-               p = "findfs";
-
-       fprintf(stderr, _("Usage: %s LABEL=<label>|UUID=<uuid>\n"), p);
+       FILE *out = rc ? stderr : stdout;
+       fputs(USAGE_HEADER, out);
+       fprintf(out, _(" %1$s [options] LABEL=<label>\n"
+                      " %1$s [options] UUID=<uuid>\n"),
+               program_invocation_short_name);
+       fputs(USAGE_OPTIONS, out);
+       fputs(USAGE_HELP, out);
+       fputs(USAGE_VERSION, out);
+       fprintf(out, USAGE_MAN_TAIL("findfs(8)"));
        exit(rc);
 }
 
@@ -44,8 +47,12 @@ int main(int argc, char **argv)
        } else if (!strncmp(argv[1], "UUID=", 5)) {
                tk = "UUID";
                vl = argv[1] + 5;
-       } else if (!strcmp(argv[1], "-h") == 0 ||
-                  !strcmp(argv[1], "--help") == 0) {
+       } else if (strcmp(argv[1], "-V") == 0 ||
+                  strcmp(argv[1], "--version") == 0) {
+               printf(UTIL_LINUX_VERSION);
+               return EXIT_SUCCESS;
+       } else if (strcmp(argv[1], "-h") == 0 ||
+                  strcmp(argv[1], "--help") == 0) {
                usage(EXIT_SUCCESS);
        } else
                usage(2);