mirror of
https://github.com/openbsd/src.git
synced 2025-01-04 23:35:36 -08:00
Switch (non-curses, non-ksh) programs that use COLUMNS to a single idiom.
Previously behaviors were all over the map. This changes them to use COLUMNS first, and either terminal width or a hardcoded value (typically 80) as appropriate. ok deraadt@; man bits ok jmc@
This commit is contained in:
parent
8a98f13cf9
commit
7220d8ecee
14
bin/ls/ls.1
14
bin/ls/ls.1
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: ls.1,v 1.74 2016/03/11 02:35:57 bentley Exp $
|
||||
.\" $OpenBSD: ls.1,v 1.75 2016/03/17 05:27:10 bentley Exp $
|
||||
.\" $NetBSD: ls.1,v 1.14 1995/12/05 02:44:01 jtc Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
|
||||
@ -33,7 +33,7 @@
|
||||
.\"
|
||||
.\" @(#)ls.1 8.7 (Berkeley) 7/29/94
|
||||
.\"
|
||||
.Dd $Mdocdate: March 11 2016 $
|
||||
.Dd $Mdocdate: March 17 2016 $
|
||||
.Dt LS 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -436,10 +436,12 @@ option is not specified, the block counts
|
||||
.Fl s )
|
||||
will be displayed in units of that size block.
|
||||
.It Ev COLUMNS
|
||||
If this variable contains a string representing a
|
||||
decimal integer, it is used as the
|
||||
column position width for displaying
|
||||
multiple-text-column output.
|
||||
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 LC_CTYPE
|
||||
If set to a string ending in
|
||||
.Qq .UTF-8 ,
|
||||
|
26
bin/ls/ls.c
26
bin/ls/ls.c
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ls.c,v 1.44 2015/12/01 18:36:13 schwarze Exp $ */
|
||||
/* $OpenBSD: ls.c,v 1.45 2016/03/17 05:27:10 bentley Exp $ */
|
||||
/* $NetBSD: ls.c,v 1.18 1996/07/09 09:16:29 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
@ -66,7 +66,7 @@ static int (*sortfcn)(const FTSENT *, const FTSENT *);
|
||||
#define BY_TIME 2
|
||||
|
||||
long blocksize; /* block size units */
|
||||
int termwidth = 80; /* default terminal width */
|
||||
int termwidth; /* default terminal width */
|
||||
int sortkey = BY_NAME;
|
||||
|
||||
/* flags */
|
||||
@ -110,24 +110,20 @@ ls_main(int argc, char *argv[])
|
||||
|
||||
/* Terminal defaults to -Cq, non-terminal defaults to -1. */
|
||||
if (isatty(STDOUT_FILENO)) {
|
||||
if ((p = getenv("COLUMNS")) != NULL)
|
||||
width = strtonum(p, 1, INT_MAX, NULL);
|
||||
if (width == 0 &&
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 &&
|
||||
win.ws_col > 0)
|
||||
width = win.ws_col;
|
||||
if (width)
|
||||
termwidth = width;
|
||||
f_column = f_nonprint = 1;
|
||||
} else {
|
||||
f_singlecol = 1;
|
||||
/* retrieve environment variable, in case of explicit -C */
|
||||
if ((p = getenv("COLUMNS")) != NULL)
|
||||
width = strtonum(p, 0, INT_MAX, NULL);
|
||||
if (width)
|
||||
termwidth = width;
|
||||
}
|
||||
|
||||
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 (pledge("stdio rpath getpw", NULL) == -1)
|
||||
err(1, "pledge");
|
||||
|
||||
|
13
bin/ps/ps.1
13
bin/ps/ps.1
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: ps.1,v 1.102 2015/10/22 22:21:41 benno Exp $
|
||||
.\" $OpenBSD: ps.1,v 1.103 2016/03/17 05:27:10 bentley Exp $
|
||||
.\" $NetBSD: ps.1,v 1.16 1996/03/21 01:36:28 jtc Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
|
||||
@ -30,7 +30,7 @@
|
||||
.\"
|
||||
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
|
||||
.\"
|
||||
.Dd $Mdocdate: October 22 2015 $
|
||||
.Dd $Mdocdate: March 17 2016 $
|
||||
.Dt PS 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -543,10 +543,13 @@ The following environment variables affect the execution of
|
||||
.Nm :
|
||||
.Bl -tag -width "COLUMNS"
|
||||
.It Ev COLUMNS
|
||||
If set, specifies the user's preferred output width in column positions.
|
||||
By default,
|
||||
If set to a positive integer,
|
||||
.Nm Ns 's
|
||||
output is formatted to the given width in columns.
|
||||
Otherwise,
|
||||
.Nm
|
||||
attempts to automatically determine the terminal width.
|
||||
defaults to the terminal width \(mi 1, or 79 columns if the output is not a
|
||||
terminal.
|
||||
.It Ev TZ
|
||||
The time zone to use when displaying dates.
|
||||
See
|
||||
|
26
bin/ps/ps.c
26
bin/ps/ps.c
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ps.c,v 1.69 2016/01/10 14:04:16 schwarze Exp $ */
|
||||
/* $OpenBSD: ps.c,v 1.70 2016/03/17 05:27:10 bentley Exp $ */
|
||||
/* $NetBSD: ps.c,v 1.15 1995/05/18 20:33:25 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
@ -102,22 +102,14 @@ main(int argc, char *argv[])
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
|
||||
if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0') {
|
||||
const char *errstr;
|
||||
|
||||
termwidth = strtonum(cols, 1, INT_MAX, &errstr);
|
||||
if (errstr != NULL)
|
||||
warnx("COLUMNS: %s: %s", cols, errstr);
|
||||
}
|
||||
if (termwidth == 0) {
|
||||
if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1 &&
|
||||
ioctl(STDERR_FILENO, TIOCGWINSZ, &ws) == -1 &&
|
||||
ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == -1) ||
|
||||
ws.ws_col == 0)
|
||||
termwidth = 79;
|
||||
else
|
||||
termwidth = ws.ws_col - 1;
|
||||
}
|
||||
termwidth = 0;
|
||||
if ((cols = getenv("COLUMNS")) != NULL)
|
||||
termwidth = strtonum(cols, 1, INT_MAX, NULL);
|
||||
if (termwidth == 0 && ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0 &&
|
||||
ws.ws_col > 0)
|
||||
termwidth = ws.ws_col - 1;
|
||||
if (termwidth == 0)
|
||||
termwidth = 79;
|
||||
|
||||
if (argc > 1)
|
||||
argv[1] = kludge_oldps_options(argv[1]);
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: growfs.8,v 1.12 2013/10/19 16:53:13 schwarze Exp $
|
||||
.\" $OpenBSD: growfs.8,v 1.13 2016/03/17 05:27:10 bentley Exp $
|
||||
.\" Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz
|
||||
.\" Copyright (c) 1980, 1989, 1993 The Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
@ -38,7 +38,7 @@
|
||||
.\" $TSHeader: src/sbin/growfs/growfs.8,v 1.3 2000/12/12 19:31:00 tomsoft Exp $
|
||||
.\" $FreeBSD: src/sbin/growfs/growfs.8,v 1.24 2005/01/18 10:09:34 ru Exp $
|
||||
.\"
|
||||
.Dd $Mdocdate: October 19 2013 $
|
||||
.Dd $Mdocdate: March 17 2016 $
|
||||
.Dt GROWFS 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -110,6 +110,15 @@ The
|
||||
flag suppresses this,
|
||||
so use this option with great care!
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width COLUMNS
|
||||
.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.
|
||||
.Sh SEE ALSO
|
||||
.Xr disklabel 8 ,
|
||||
.Xr dumpfs 8 ,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: growfs.c,v 1.49 2016/01/29 11:50:40 tb Exp $ */
|
||||
/* $OpenBSD: growfs.c,v 1.50 2016/03/17 05:27:10 bentley Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz
|
||||
* Copyright (c) 1980, 1989, 1993 The Regents of the University of California.
|
||||
@ -1666,15 +1666,13 @@ charsperline(void)
|
||||
struct winsize ws;
|
||||
|
||||
columns = 0;
|
||||
if (ioctl(0, TIOCGWINSZ, &ws) != -1) {
|
||||
columns = ws.ws_col;
|
||||
}
|
||||
if (columns == 0 && (cp = getenv("COLUMNS"))) {
|
||||
if ((cp = getenv("COLUMNS")) != NULL)
|
||||
columns = strtonum(cp, 1, INT_MAX, NULL);
|
||||
}
|
||||
if (columns == 0) {
|
||||
columns = 80; /* last resort */
|
||||
}
|
||||
if (columns == 0 && ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0 &&
|
||||
ws.ws_col > 0)
|
||||
columns = ws.ws_col;
|
||||
if (columns == 0)
|
||||
columns = 80;
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: mkfs.c,v 1.95 2016/01/28 17:26:10 gsoares Exp $ */
|
||||
/* $OpenBSD: mkfs.c,v 1.96 2016/03/17 05:27:10 bentley Exp $ */
|
||||
/* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -1144,12 +1144,14 @@ charsperline(void)
|
||||
struct winsize ws;
|
||||
|
||||
columns = 0;
|
||||
if (ioctl(0, TIOCGWINSZ, &ws) != -1)
|
||||
columns = ws.ws_col;
|
||||
if (columns == 0 && (cp = getenv("COLUMNS")))
|
||||
if ((cp = getenv("COLUMNS")) != NULL)
|
||||
columns = strtonum(cp, 1, INT_MAX, NULL);
|
||||
if (columns == 0 && ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0 &&
|
||||
ws.ws_col > 0)
|
||||
columns = ws.ws_col;
|
||||
if (columns == 0)
|
||||
columns = 80; /* last resort */
|
||||
columns = 80;
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: newfs.8,v 1.72 2016/02/18 21:57:26 jmc Exp $
|
||||
.\" $OpenBSD: newfs.8,v 1.73 2016/03/17 05:27:10 bentley Exp $
|
||||
.\" $NetBSD: newfs.8,v 1.12 1995/03/18 14:58:41 cgd Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1983, 1987, 1991, 1993, 1994
|
||||
@ -30,7 +30,7 @@
|
||||
.\"
|
||||
.\" @(#)newfs.8 8.3 (Berkeley) 3/27/94
|
||||
.\"
|
||||
.Dd $Mdocdate: February 18 2016 $
|
||||
.Dd $Mdocdate: March 17 2016 $
|
||||
.Dt NEWFS 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -301,6 +301,16 @@ If the
|
||||
.Fl P Ar file
|
||||
option is not used, the owner and mode of the created mfs file
|
||||
system will be the same as the owner and mode of the mount point.
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width COLUMNS
|
||||
.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.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr disktab 5 ,
|
||||
.Xr fs 5 ,
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: column.1,v 1.14 2015/03/13 19:58:41 jmc Exp $
|
||||
.\" $OpenBSD: column.1,v 1.15 2016/03/17 05:27:10 bentley Exp $
|
||||
.\" $NetBSD: column.1,v 1.3 1995/03/26 09:08:28 glass Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1989, 1990, 1993
|
||||
@ -30,7 +30,7 @@
|
||||
.\"
|
||||
.\" @(#)column.1 8.1 (Berkeley) 6/6/93
|
||||
.\"
|
||||
.Dd $Mdocdate: March 13 2015 $
|
||||
.Dd $Mdocdate: March 17 2016 $
|
||||
.Dt COLUMN 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -75,10 +75,12 @@ Fill columns before filling rows.
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width COLUMNS
|
||||
.It Ev COLUMNS
|
||||
The environment variable
|
||||
.Ev COLUMNS
|
||||
is used to determine the size of
|
||||
the screen if no other information is available.
|
||||
If set to a positive integer,
|
||||
.Nm Ns 's
|
||||
output is formatted to the given width in (terminal) columns.
|
||||
Otherwise,
|
||||
.Nm
|
||||
defaults to the terminal width, or 80 columns if the output is not a terminal.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Ex -std column
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: column.c,v 1.22 2015/11/03 04:55:44 mmcc Exp $ */
|
||||
/* $OpenBSD: column.c,v 1.23 2016/03/17 05:27:10 bentley Exp $ */
|
||||
/* $NetBSD: column.c,v 1.4 1995/09/02 05:53:03 jtc Exp $ */
|
||||
|
||||
/*
|
||||
@ -50,7 +50,7 @@ void print(void);
|
||||
void r_columnate(void);
|
||||
void usage(void);
|
||||
|
||||
int termwidth = 80; /* default terminal width */
|
||||
int termwidth; /* default terminal width */
|
||||
|
||||
int entries; /* number of records */
|
||||
int eval; /* exit value */
|
||||
@ -67,14 +67,14 @@ main(int argc, char *argv[])
|
||||
char *p;
|
||||
const char *errstr;
|
||||
|
||||
if (ioctl(1, TIOCGWINSZ, &win) == -1 || !win.ws_col) {
|
||||
if ((p = getenv("COLUMNS")) && *p != '\0') {
|
||||
termwidth = strtonum(p, 1, INT_MAX, &errstr);
|
||||
if (errstr != NULL)
|
||||
errx(1, "%s: %s", errstr, p);
|
||||
}
|
||||
} else
|
||||
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 (pledge("stdio rpath", NULL) == -1)
|
||||
err(1, "pledge");
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: rusers.1,v 1.15 2014/04/24 15:03:04 tedu Exp $
|
||||
.\" $OpenBSD: rusers.1,v 1.16 2016/03/17 05:27:10 bentley Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1983, 1990 The Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" from: @(#)rusers.1 6.7 (Berkeley) 4/23/91
|
||||
.\"
|
||||
.Dd $Mdocdate: April 24 2014 $
|
||||
.Dd $Mdocdate: March 17 2016 $
|
||||
.Dt RUSERS 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -79,6 +79,16 @@ and the remote host they logged in from (if applicable).
|
||||
.It Fl u
|
||||
Sort by number of users logged in.
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width COLUMNS
|
||||
.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.
|
||||
.El
|
||||
.Sh DIAGNOSTICS
|
||||
.Bl -tag -width indent
|
||||
.It rusers: RPC: Program not registered
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: rusers.c,v 1.36 2015/12/09 19:39:10 mmcc Exp $ */
|
||||
/* $OpenBSD: rusers.c,v 1.37 2016/03/17 05:27:10 bentley Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, 2003 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
@ -141,21 +141,15 @@ main(int argc, char **argv)
|
||||
if (hflag + iflag + uflag > 1)
|
||||
usage();
|
||||
|
||||
if (isatty(STDOUT_FILENO)) {
|
||||
if ((cp = getenv("COLUMNS")) != NULL && *cp != '\0') {
|
||||
termwidth = strtol(cp, &ep, 10);
|
||||
if (*ep != '\0' || termwidth >= INT_MAX ||
|
||||
termwidth < 0)
|
||||
termwidth = 0;
|
||||
}
|
||||
if (termwidth == 0 &&
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 &&
|
||||
win.ws_col > 0)
|
||||
termwidth = win.ws_col;
|
||||
else
|
||||
termwidth = 80;
|
||||
} else
|
||||
termwidth = 0;
|
||||
if ((cp = getenv("COLUMNS")) != NULL)
|
||||
termwidth = strtonum(cp, 1, LONG_MAX, NULL);
|
||||
if (termwidth == 0 && ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 &&
|
||||
win.ws_col > 0)
|
||||
termwidth = win.ws_col;
|
||||
if (termwidth == 0)
|
||||
termwidth = 80;
|
||||
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
|
||||
if (argc == optind) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.31 2016/01/01 20:55:13 tb Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.32 2016/03/17 05:27:10 bentley Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992 Diomidis Spinellis.
|
||||
@ -150,14 +150,14 @@ main(int argc, char *argv[])
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if ((p = getenv("COLUMNS")))
|
||||
termwidth = 0;
|
||||
if ((p = getenv("COLUMNS")) != NULL)
|
||||
termwidth = strtonum(p, 0, INT_MAX, NULL);
|
||||
if (termwidth == 0 &&
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 &&
|
||||
if (termwidth == 0 && ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 &&
|
||||
win.ws_col > 0)
|
||||
termwidth = win.ws_col;
|
||||
if (termwidth == 0)
|
||||
termwidth = 60;
|
||||
termwidth = 80;
|
||||
|
||||
if (inplace != NULL) {
|
||||
if (pledge("stdio rpath wpath cpath fattr", NULL) == -1)
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: sed.1,v 1.47 2015/11/04 21:28:27 tedu Exp $
|
||||
.\" $OpenBSD: sed.1,v 1.48 2016/03/17 05:27:10 bentley Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1992, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -32,7 +32,7 @@
|
||||
.\"
|
||||
.\" from: @(#)sed.1 8.2 (Berkeley) 12/30/93
|
||||
.\"
|
||||
.Dd $Mdocdate: November 4 2015 $
|
||||
.Dd $Mdocdate: March 17 2016 $
|
||||
.Dt SED 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -512,6 +512,17 @@ This is the same as specifying the
|
||||
.Fl n
|
||||
option on the command line.
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width COLUMNS
|
||||
.It Ev COLUMNS
|
||||
If set to a positive integer,
|
||||
output from the
|
||||
.Ic l
|
||||
function is formatted to the given width in columns.
|
||||
Otherwise,
|
||||
.Nm
|
||||
defaults to the terminal with, or 80 columns if the output is not a terminal.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Ex -std sed
|
||||
.Sh EXAMPLES
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user