diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-02-17 18:49:23 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-02-17 18:49:23 +0000 |
commit | f6907ab40fc8a4a9f2fdacff9999021113cb21ee (patch) | |
tree | 60e0481dcfc53e257e0e6ab026517a9e7edd2e14 /bin | |
parent | fdca4f340f42ded00bd3cd6e22e3ebfc8c428d3d (diff) |
From netbsd:
Changed so that COLUMNS environment variable will override the value
obtained via the TIOCGWINSIZ ioctl. This is required by POSIX.2, see
section 4.39.5.3.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ls/ls.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c index c64d7c8e657..2fc2ef8d43b 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -1,4 +1,4 @@ -/* $NetBSD: ls.c,v 1.15 1995/09/07 06:42:58 jtc Exp $ */ +/* $NetBSD: ls.c,v 1.16 1996/02/14 05:58:53 jtc Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -46,7 +46,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)ls.c 8.7 (Berkeley) 8/5/94"; #else -static char rcsid[] = "$NetBSD: ls.c,v 1.15 1995/09/07 06:42:58 jtc Exp $"; +static char rcsid[] = "$NetBSD: ls.c,v 1.16 1996/02/14 05:58:53 jtc Exp $"; #endif #endif /* not lint */ @@ -118,12 +118,10 @@ main(argc, 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 + if ((p = getenv("COLUMNS")) != NULL) + termwidth = atoi(p); + else if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 && + win.ws_col > 0) termwidth = win.ws_col; f_column = f_nonprint = 1; } else |