Re: Proposed patch - psql wraps at window width

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Aidan Van Dyk <aidan(at)highrise(dot)ca>, Gregory Stark <stark(at)enterprisedb(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Bryce Nesbitt <bryce2(at)obviously(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Brendan Jurd <direvus(at)gmail(dot)com>, heikki(at)enterprisedb(dot)com
Subject: Re: Proposed patch - psql wraps at window width
Date: 2008-05-06 16:06:32
Message-ID: 200805061606.m46G6WF10021@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Aidan Van Dyk <aidan(at)highrise(dot)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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-05-06 16:06:53 Re: Proposed patch - psql wraps at window width
Previous Message Peter Eisentraut 2008-05-06 16:00:47 Re: Proposed patch - psql wraps at window width