diff options
author | Elliott Hughes <enh@google.com> | 2019-08-17 21:14:12 -0700 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-08-23 11:02:47 -0500 |
commit | 0b51fcccf097f70cfd033fee1c983b4dc8d214b7 (patch) | |
tree | 3da91dc6c9a00a9b5adda794c6477ffa07e73589 /toys/pending | |
parent | d6bb677517c5bd06983c3163e680b1f77717af2c (diff) | |
download | toybox-0b51fcccf097f70cfd033fee1c983b4dc8d214b7.tar.gz |
man: fix help, align -k output, and fix double close.
The "info" pages are something very different from the "intro" pages :-)
do_lines already closes the fd.
Also improve the error message for `man`.
Diffstat (limited to 'toys/pending')
-rw-r--r-- | toys/pending/man.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/toys/pending/man.c b/toys/pending/man.c index 7063df09..892d367c 100644 --- a/toys/pending/man.c +++ b/toys/pending/man.c @@ -10,20 +10,20 @@ config MAN bool "man" default n help - usage: man [-k STRING] | [SECTION] COMMAND + usage: man [-M PATH] [-k STRING] | [SECTION] COMMAND Read manual page for system command. - -k Search short + -k List pages with STRING in their short description + -M Override $MANPATH - Man pages are divided into 8 sections, each with an info page (man 8 info). - 1) executables, 2) syscalls, 3) library functions, 4) /dev files, - 5) file formats (ala /etc/hosts), 6) games, 7) miscelanous, 8) sysadmin + Man pages are divided into 8 sections: + 1 commands 2 system calls 3 library functions 4 /dev files + 5 file formats 6 games 7 miscellaneous 8 system management - If you don't specify a section it'll show the lowest numbered one, - but "man 1 mkdir" and "man 2 mkdir" are different things. - - The shell builtins don't have section 1 man pages, see the "help" command. + Sections are searched in the order 1 8 3 2 5 4 6 7 unless you specify a + section. Each section has a page called "intro", and there's a global + introduction under "man-pages". */ #define FOR_man @@ -84,7 +84,7 @@ static void do_man(char **pline, long len) if (FLAG(k)) { if (!TT.k_done && !start(".") && !start("'") && k(strstr(*pline, "- "))) - printf("%s %s%s", TT.k, "- "+2*(TT.line!=*pline), TT.line); + printf("%-20s %s%s", TT.k, "- "+2*(TT.line!=*pline), TT.line); else if (!TT.k_done && start(".so") && k(basename(*pline + 4))) printf("%s - See %s", TT.k, TT.line); } else { @@ -186,7 +186,6 @@ void man_main(void) if (-1 != (fd = zopen(f))) { TT.k_done = 0; do_lines(fd, '\n', do_man); - close(fd); } free(f); } @@ -196,7 +195,7 @@ void man_main(void) return regfree(&TT.reg); } - if (!toys.optc) error_exit("not yet"); + if (!toys.optc) help_exit("which page?"); if (toys.optc == 1) { if (strchr(*toys.optargs, '/')) fd = zopen(*toys.optargs); |