Skip site navigation (1) Skip section navigation (2)

Re: Proposed patch - psql wraps at window width

From: Bryce Nesbitt <bryce2(at)obviously(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Bruce Momjian <bruce(at)momjian(dot)us>, heikki(at)enterprisedb(dot)com, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Proposed patch - psql wraps at window width
Date: 2008-04-18 07:11:58
Message-ID: 480849BE.4050409@obviously.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Peter Eisentraut wrote:
> Bruce Momjian wrote:
>   
>> I checked the use of COLUMNS and it seems bash updates the environment
>> variable when a window is resized.  I added ioctl(TIOCGWINSZ) if COLUMNS
>> isn't set.  We already had a call in print.c for detecting the
>> number of rows on the screen to determine if the pager should
>> be used.  Seems COLUMNS should take precedence over ioctl(), right?    
>
> Considering that the code to determine the row count is undisputed so far, the 
> column count detection should work the same.  That is, we might not need to 
> look at COLUMNS at all.  Unless there is a use case for overriding the column 
> count (instead of just turning off the wrapping).
>   
I asked the folks over at "Experts Exchange" to test the behavior of the 
ioctl and $COLUMNS on various platforms.  I'd been told that I would 
face huge problems if a console was resized.  But the results were 
pretty consistent, and nothing had problems with resize:  
http://www.experts-exchange.com/Programming/Open_Source/Q_23243646.html

It appears impossible to override $COLUMNS, on some platforms as the 
readline call sets it.
On many platforms $COLUMNS is null until the call to readline.
OSX does not set $COLUMNS at all.

In short, I recommend the ioctl instead.  In order to provide a way to 
wrap output to a pipe, I think a different mechanism will have to be found.

                         -Bryce


In response to

pgsql-hackers by date

Next:From: Magnus HaganderDate: 2008-04-18 07:26:43
Subject: Re: Coding standards
Previous:From: Martijn van OosterhoutDate: 2008-04-18 07:09:27
Subject: Re: Re: [COMMITTERS] pgsql: Repair two places where SIGTERM exit couldleave shared memory

pgsql-patches by date

Next:From: Magnus HaganderDate: 2008-04-18 07:26:43
Subject: Re: Coding standards
Previous:From: Bryce NesbittDate: 2008-04-18 07:07:29
Subject: Re: Proposed patch - psql wraps at window width

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group