]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
pg.c: Add --help and --version
authorJari Aalto <jari.aalto@cante.net>
Fri, 14 Jun 2013 09:42:27 +0000 (12:42 +0300)
committerKarel Zak <kzak@redhat.com>
Tue, 18 Jun 2013 08:49:35 +0000 (10:49 +0200)
[kzak@redhat.com: - use USAGE_{HELP,VERISON} macros]

Signed-off-by: Jari Aalto <jari.aalto@cante.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
text-utils/pg.c

index 7ddf96bf98da35223c75086fea5000ecd0db7fcc..7b61e6bd37bd24d9a6b671ff60294b6f2893f2b1 100644 (file)
@@ -224,8 +224,11 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
        fputs(_(" -s           print messages to stdout\n"), out);
        fputs(_(" +number      start at the given line\n"), out);
        fputs(_(" +/pattern/   start at the line containing pattern\n"), out);
-       fputs(_(" -h           display this help and exit\n"), out);
-       fputs(_(" -V           output version information and exit\n"), out);
+
+       fputs(USAGE_SEPARATOR, out);
+       fputs(USAGE_HELP, out);
+       fputs(USAGE_VERSION, out);
+
        fprintf(out, USAGE_MAN_TAIL("pg(1)"));
        quit(out == stderr ? 2 : 0);
 }
@@ -1542,6 +1545,16 @@ int main(int argc, char **argv)
                if (*argv[arg] != '-' || argv[arg][1] == '\0')
                        break;
                argc--;
+
+               if (!strcmp(argv[arg], "--help")) {
+                   usage(stdout);
+               }
+
+               if (!strcmp(argv[arg], "--version")) {
+                   printf(UTIL_LINUX_VERSION);
+                   return EXIT_SUCCESS;
+               }
+
                for (i = 1; argv[arg][i]; i++) {
                        switch (argv[arg][i]) {
                        case '-':