diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-12-09 22:59:57 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-12-09 22:59:57 +0100 |
commit | e632349ce9ab655bc5628656fb9b1177faf37095 (patch) | |
tree | a27409582be940fa0c308f9700826ed02b82787a | |
parent | feb158c34f8eb5dddf83c9f99ced73c92c70f8d1 (diff) |
Literally open grab(1) when someone uses -h
-rw-r--r-- | grab.1 | 2 | ||||
-rw-r--r-- | grab.c | 12 |
2 files changed, 12 insertions, 2 deletions
@@ -9,6 +9,8 @@ .Op Fl z .Ar pattern .Op Ar +.Nm +.Fl h .Sh DESCRIPTION .Sh EXIT STATUS .Ex -std @@ -1,5 +1,6 @@ #include <assert.h> #include <err.h> +#include <libgen.h> #include <limits.h> #include <locale.h> #include <regex.h> @@ -66,7 +67,10 @@ static const cmd_func op_table[UCHAR_MAX] = { static void usage(const char *s) { - fprintf(stderr, "Usage: %s [-d string] pattern [file ...]\n", s); + fprintf(stderr, + "Usage: %s [-z] pattern [file ...]\n" + " %s -h\n", + s, s); exit(EXIT_FAILURE); } @@ -76,13 +80,17 @@ main(int argc, char **argv) int rv, opt; struct ops ops; + argv[0] = basename(argv[0]); if (argc < 2) usage(argv[0]); setlocale(LC_ALL, ""); - while ((opt = getopt(argc, argv, "z")) != -1) { + while ((opt = getopt(argc, argv, "hz")) != -1) { switch (opt) { + case 'h': + if (execlp("man", "man", "1", argv[0], NULL) == -1) + die("execlp: man 1 %s", argv[0]); case 'z': delim = '\0'; break; |