* Copyright (C) 2008 Denys Vlasenko <vda.linux@googlemail.com>
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
+//config:config MAN
+//config: bool "man (27 kb)"
+//config: default y
+//config: help
+//config: Format and display manual pages.
+
+//applet:IF_MAN(APPLET(man, BB_DIR_USR_BIN, BB_SUID_DROP))
+
+//kbuild:lib-$(CONFIG_MAN) += man.o
//usage:#define man_trivial_usage
//usage: "[-aw] [MANPAGE]..."
//usage: "Format and display manual page\n"
//usage: "\n -a Display all pages"
//usage: "\n -w Show page locations"
+//usage: "\n"
+//usage: "\n$COLUMNS overrides output width"
#include "libbb.h"
#include "common_bufsiz.h"
echo ".pl \n(nlu+10"
) | gtbl | nroff -Tlatin1 -mandoc | less
+Some systems use -Tascii.
+
On another system I see this:
... | tbl | nroff -mandoc -rLL=<NNN>n -rLT=<NNN>n -Tutf8 | less
setup_common_bufsiz(); \
G.col = "col"; \
G.tbl = "tbl"; \
- /* replaced -Tlatin1 with -Tascii for non-UTF8 displays */; \
- G.nroff = "nroff -mandoc -Tascii"; \
+ /* Removed -Tlatin1. Assuming system nroff has suitable default */ \
+ G.nroff = "nroff -mandoc"; \
G.pager = ENABLE_LESS ? "less" : "more"; \
} while (0)
close(STDIN_FILENO);
open_zipped(man_filename, /*fail_if_not_compressed:*/ 0); /* guaranteed to use fd 0 (STDIN_FILENO) */
if (man) {
- /* "man man" formats to screen width.
- * "man man >file" formats to default 80 columns.
- * "man man | cat" formats to default 80 columns.
- */
- int w = get_terminal_width(STDOUT_FILENO);
+ int w = get_terminal_width(-1);
if (w > 10)
w -= 2;
/* "2>&1" is added so that nroff errors are shown in pager too.
- * Otherwise it may show just empty screen */
+ * Otherwise it may show just empty screen.
+ */
cmd = xasprintf("%s | %s -rLL=%un -rLT=%un 2>&1 | %s",
G.tbl, G.nroff, w, w,
G.pager);
INIT_G();
- opt_complementary = "-1"; /* at least one argument */
- opt = getopt32(argv, "+aw");
+ opt = getopt32(argv, "^+" "aw" "\0" "-1"/*at least one arg*/);
argv += optind;
sec_list = xstrdup("0p:1:1p:2:3:3p:4:5:6:7:8:9");