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

From Bruce Momjian
Subject Re: Proposed patch - psql wraps at window width
Date
Msg-id 200805061606.m46G6WF10021@momjian.us
Whole thread Raw
In response to Re: Proposed patch - psql wraps at window width  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> Aidan Van Dyk <aidan@highrise.ca> writes:
> > But one of the interesting things is that psql has an is *interactive*
> > mode (something the GNU utils don't have to worry about).  So *when* you
> > choose to figure out your columns is important, and really impacts
> > behaviour too.
> 
> Well, COLUMNS has no hope of tracking on-the-fly changes of window size,
> which is why the ioctl should take precedence over it.

True, but Peter wanted COLUMNS to be honored over ioctl():
http://archives.postgresql.org/pgsql-hackers/2008-04/msg01853.php

> > Correctly documenting it is good, just as the version of GNU ls I have
> > on Debian, where I see:
> >     `-w'
> >     `--width=COLS'
> >          Assume the screen is COLS columns wide.  The default is taken from
> >          the terminal settings if possible; otherwise the environment
> >          variable `COLUMNS' is used if it is set; otherwise the default is
> >          80.
> 
> Fedora 8 has the same wording in "info ls".  Possibly Bruce was reading
> the man page, which is not as complete (and admits it).

Oh, you are looking at info.  That makes sense now.

> Experimentation on OS X (BSD clone) shows that its "ls" believes COLUMNS
> in preference to ioctl, so there's clearly scope for argument; but on
> the whole I think we should follow the GNU behavior.  The BSD version's
> behavior is full of enormous amounts of historical cruft (and its man
> page admits that) --- I suspect the behavior on this point "just grew"
> instead of being carefully thought about.

Well, the GNU 'ls' behavior, because it does not check for isatty(),
will use COLUMNS mostly for file/pipe output because those are the cases
where ioctl() fails.  Is that what you want?

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Proposed patch - psql wraps at window width
Next
From: Tom Lane
Date:
Subject: Re: Proposed patch - psql wraps at window width