diff options
author | Roy Marples <roy@marples.name> | 2007-10-03 11:49:08 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-10-03 11:49:08 +0000 |
commit | 932a4576ce371ae9bdf290f24e76240ec71fb482 (patch) | |
tree | ce39e6bb1333cda00327c5410ff57c17c169fa80 | |
parent | b675ca477932acda8d306e4bc3b5cb3c05cd8f44 (diff) |
Respect COLUMNS
-rw-r--r-- | src/libeinfo.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libeinfo.c b/src/libeinfo.c index f7b62b5c..f157423f 100644 --- a/src/libeinfo.c +++ b/src/libeinfo.c @@ -176,6 +176,15 @@ static bool colour_terminal (void) static int get_term_columns (FILE *stream) { struct winsize ws; + char *env = getenv ("COLUMNS"); + char *p; + int i; + + if (env) { + i = strtol (env, &p, 10); + if (! *p) + return (i); + } if (ioctl (fileno (stream), TIOCGWINSZ, &ws) == 0) return (ws.ws_col); |