From 34e38ad0c3be0856d7f62d4550cec0305bca6910 Mon Sep 17 00:00:00 2001 From: Jari Aalto Date: Fri, 14 Jun 2013 12:42:27 +0300 Subject: pg.c: Add --help and --version [kzak@redhat.com: - use USAGE_{HELP,VERISON} macros] Signed-off-by: Jari Aalto Signed-off-by: Karel Zak --- text-utils/pg.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'text-utils') diff --git a/text-utils/pg.c b/text-utils/pg.c index 7ddf96bf9..7b61e6bd3 100644 --- a/text-utils/pg.c +++ b/text-utils/pg.c @@ -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 '-': -- cgit v1.2.3-55-g7522