aboutsummaryrefslogtreecommitdiff
path: root/src/libeinfo.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-10-03 11:49:08 +0000
committerRoy Marples <roy@marples.name>2007-10-03 11:49:08 +0000
commit932a4576ce371ae9bdf290f24e76240ec71fb482 (patch)
treece39e6bb1333cda00327c5410ff57c17c169fa80 /src/libeinfo.c
parentb675ca477932acda8d306e4bc3b5cb3c05cd8f44 (diff)
Respect COLUMNS
Diffstat (limited to 'src/libeinfo.c')
-rw-r--r--src/libeinfo.c9
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);