summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko2016-10-31 01:52:18 +0100
committerDenys Vlasenko2016-10-31 01:52:18 +0100
commit7c3c92c533b65d4c29f2990915c9c424c3f6629d (patch)
treed9eb784d9c458c3d91fcf9a9e31e636f39d8a360 /miscutils
parenta92a74961d838209f3468d10426bc945ba26070c (diff)
downloadbusybox-7c3c92c533b65d4c29f2990915c9c424c3f6629d.zip
busybox-7c3c92c533b65d4c29f2990915c9c424c3f6629d.tar.gz
man: make width selection more thorough; explain how to override it
Fedora's "man CMD >file" still uses terminal width, not 80 (but disables formatting), this change mimics that. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/man.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/miscutils/man.c b/miscutils/man.c
index 01382c4..adb7770 100644
--- a/miscutils/man.c
+++ b/miscutils/man.c
@@ -9,6 +9,8 @@
//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"
@@ -53,7 +55,7 @@ struct globals {
setup_common_bufsiz(); \
G.col = "col"; \
G.tbl = "tbl"; \
- /* replaced -Tlatin1 with -Tascii for non-UTF8 displays */; \
+ /* replaced -Tlatin1 with -Tascii for non-UTF8 displays */ \
G.nroff = "nroff -mandoc -Tascii"; \
G.pager = ENABLE_LESS ? "less" : "more"; \
} while (0)
@@ -132,15 +134,12 @@ static int run_pipe(char *man_filename, int man, int level)
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);