diff options
author | Tim J. Robbins <tjr@FreeBSD.org> | 2002-06-04 10:11:29 +0000 |
---|---|---|
committer | Tim J. Robbins <tjr@FreeBSD.org> | 2002-06-04 10:11:29 +0000 |
commit | a28edf9a4a68207a93b90a9ba71617467957e257 (patch) | |
tree | 143a21a2cc0ca32a52d1a6f8460f624d67663dde /bin/ls/ls.c | |
parent | 30e9580ecae64bbc4450342fe67db0f6ab3eeb62 (diff) | |
download | src-a28edf9a4a68207a93b90a9ba71617467957e257.tar.gz src-a28edf9a4a68207a93b90a9ba71617467957e257.zip |
Ignore empty COLUMNS environment variable. COLUMNS should take precedence
over TTY width found via ioctl() (SUSv3)
Notes
Notes:
svn path=/head/; revision=97803
Diffstat (limited to 'bin/ls/ls.c')
-rw-r--r-- | bin/ls/ls.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c index 9791f01ba805..496c980d7a6f 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -150,11 +150,11 @@ main(int argc, char *argv[]) /* Terminal defaults to -Cq, non-terminal defaults to -1. */ if (isatty(STDOUT_FILENO)) { - if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == -1 || - !win.ws_col) { - if ((p = getenv("COLUMNS")) != NULL) - termwidth = atoi(p); - } else + termwidth = 80; + if ((p = getenv("COLUMNS")) != NULL && *p != '\0') + termwidth = atoi(p); + else if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) != -1 && + win.ws_col > 0) termwidth = win.ws_col; f_nonprint = 1; } else { |