diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/lpr/common_source/displayq.c | 19 | ||||
-rw-r--r-- | usr.sbin/lpr/lpq/lpq.1 | 13 |
2 files changed, 20 insertions, 12 deletions
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c index 866191736b9..415cd581865 100644 --- a/usr.sbin/lpr/common_source/displayq.c +++ b/usr.sbin/lpr/common_source/displayq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: displayq.c,v 1.38 2016/01/12 23:35:13 tb Exp $ */ +/* $OpenBSD: displayq.c,v 1.39 2016/03/17 05:27:10 bentley Exp $ */ /* $NetBSD: displayq.c,v 1.21 2001/08/30 00:51:50 itojun Exp $ */ /* @@ -101,14 +101,15 @@ displayq(int format) struct stat statb; FILE *fp; - termwidth = 80; - if (isatty(STDOUT_FILENO)) { - if ((p = getenv("COLUMNS")) != NULL) - termwidth = atoi(p); - else if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 && - win.ws_col > 0) - termwidth = win.ws_col; - } + termwidth = 0; + if ((p = getenv("COLUMNS")) != NULL) + termwidth = strtonum(p, 1, INT_MAX, NULL); + if (termwidth == 0 && ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 && + win.ws_col > 0) + termwidth = win.ws_col; + if (termwidth == 0) + termwidth = 80; + if (termwidth < 60) termwidth = 60; diff --git a/usr.sbin/lpr/lpq/lpq.1 b/usr.sbin/lpr/lpq/lpq.1 index f2e072d4fd4..eddc42821b1 100644 --- a/usr.sbin/lpr/lpq/lpq.1 +++ b/usr.sbin/lpr/lpq/lpq.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: lpq.1,v 1.10 2007/05/31 19:20:25 jmc Exp $ +.\" $OpenBSD: lpq.1,v 1.11 2016/03/17 05:27:10 bentley Exp $ .\" $NetBSD: lpq.1,v 1.11 2002/01/19 03:23:11 wiz Exp $ .\" .\" Copyright (c) 1983, 1990, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)lpq.1 8.2 (Berkeley) 4/28/95 .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: March 17 2016 $ .Dt LPQ 1 .Os .Sh NAME @@ -96,9 +96,16 @@ warns that there is no daemon present (i.e., due to some malfunction), the .Xr lpc 8 command can be used to restart the printer daemon. .Sh ENVIRONMENT -If the following environment variable exists, it is used by +If the following environment variables exist, they are used by .Nm lpq : .Bl -tag -width PRINTER +.It Ev COLUMNS +If set to a positive integer, +.Nm Ns 's +output is formatted to the given width in columns. +Otherwise, +.Nm +defaults to the terminal width, or 80 columns if the output is not a terminal. .It Ev PRINTER Specifies an alternate default printer. .El |