summaryrefslogtreecommitdiffstats
path: root/text-utils/pg.c
diff options
context:
space:
mode:
authorSami Kerola2012-03-17 21:56:06 +0100
committerKarel Zak2012-03-30 16:48:12 +0200
commit397f49961332fa414d2840ba976aa89350b354cb (patch)
tree79dfde09c6ae492fb09dae873bcd1c1ea8f65d2a /text-utils/pg.c
parentpg: correct version printing in help screen (diff)
downloadkernel-qcow2-util-linux-397f49961332fa414d2840ba976aa89350b354cb.tar.gz
kernel-qcow2-util-linux-397f49961332fa414d2840ba976aa89350b354cb.tar.xz
kernel-qcow2-util-linux-397f49961332fa414d2840ba976aa89350b354cb.zip
pg: align with howto-usage-function.txt
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'text-utils/pg.c')
-rw-r--r--text-utils/pg.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/text-utils/pg.c b/text-utils/pg.c
index 365365575..b61b1504f 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -216,13 +216,27 @@ quit(int status)
/*
* Usage message and similar routines.
*/
-static void
-usage(void)
+static void usage(FILE * out)
{
- fprintf(stderr, _("%s: Usage: %s [-number] [-p string] [-cefnrs] "
- "[+line] [+/pattern/] [files]\n"),
- progname, progname);
- quit(2);
+ fputs(USAGE_HEADER, out);
+ fprintf(out,
+ _(" %s [options] [+line] [+/pattern/] [files]\n"),
+ program_invocation_short_name);
+ fputs(USAGE_OPTIONS, out);
+ fputs(_(" -number lines per page\n"), out);
+ fputs(_(" -c clear screen before displaying\n"), out);
+ fputs(_(" -e do not pause at end of a file\n"), out);
+ fputs(_(" -f do not split long lines\n"), out);
+ fputs(_(" -n terminate command with new line\n"), out);
+ fputs(_(" -p <prompt> specify prompt\n"), out);
+ fputs(_(" -r disallow shell escape\n"), 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);
+ fprintf(out, USAGE_MAN_TAIL("pg(1)"));
+ quit(out == stderr ? 2 : 0);
}
static void
@@ -230,14 +244,14 @@ needarg(char *s)
{
fprintf(stderr, _("%s: option requires an argument -- %s\n"),
progname, s);
- usage();
+ usage(stderr);
}
static void
invopt(char *s)
{
fprintf(stderr, _("%s: illegal option -- %s\n"), progname, s);
- usage();
+ usage(stderr);
}
#ifdef HAVE_WIDECHAR
@@ -1637,6 +1651,8 @@ main(int argc, char **argv)
case 's':
sflag = 1;
break;
+ case 'h':
+ usage(stdout);
case 'V':
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;