$NetBSD$ --- main.c.orig 2019-03-10 09:56:43.000000000 +0000 +++ main.c @@ -122,10 +122,12 @@ main(int argc, char *argv[]) struct tag_files *tag_files; struct manpage *res, *resp; const char *progname, *sec, *thisarg; + const char *errstr; char *conf_file, *defpaths, *auxpaths; char *oarg, *tagarg; + char *width; unsigned char *uc; - size_t i, sz; + size_t i, sz, w; int prio, best_prio; enum outmode outmode; int fd, startdir; @@ -317,6 +319,15 @@ main(int argc, char *argv[]) !isatty(STDOUT_FILENO)) use_pager = 0; + if (conf.output.width == 0) { + width = getenv("MANWIDTH"); + if (width != NULL && *width != '\0') { + w = strtonum(width, 1, 1000, &errstr); + if (errstr == NULL) + conf.output.width = w; + } + } + if (use_pager && (conf.output.width == 0 || conf.output.indent == 0) && ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) != -1 &&