Re: Proposed patch - psql wraps at window width - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: Proposed patch - psql wraps at window width
Date
Msg-id 87prrzu8sa.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: Proposed patch - psql wraps at window width  (Bruce Momjian <bruce@momjian.us>)
Responses Re: Proposed patch - psql wraps at window width
List pgsql-hackers
"Bruce Momjian" <bruce@momjian.us> writes:

> FYI, I looked into 'ls -C' hanlding a little more and ls (GNU coreutils)
> 5.97 honors COLUMNS _only_ in file/pipe output, not for screen output. 
> What the C code does is to read COLUMNS, then overwrite that value with
> ioctl() if it works.

Well saying "file/pipe" and "screen output" is making a lot of assumptions.
The pipe may still be ending up on the screen if it's being piped to a pager.
And a "file" could still be a terminal. Also, not all terminals support the
ioctl().

What ls does is use the same logic for all cases. When the ioctl works that
takes precedence regardless of whether it's "file/pipe" or "screen output".
When it fails it uses COLUMNS instead if set.

We really must stop thinking in terms of specific use cases. You will tie
yourselves in knots if you try to enumerate all the types of terminals, places
people redirect output, and uses people might make for the output. And it will
result in very complex, hard to explain behaviour which will surprise and
disappoint users.

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Ask me about EnterpriseDB's 24x7 Postgres support!


pgsql-hackers by date:

Previous
From: Michael Meskes
Date:
Subject: Re: ecpg localization
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Query Hints? No thanks. Data hints?