diff options
Diffstat (limited to 'bin/ls')
-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 9791f01..496c980 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 { |