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

Re: Proposed patch - psql wraps at window width

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Bryce Nesbitt" <bryce2(at)obviously(dot)com>, "Peter Eisentraut" <peter_e(at)gmx(dot)net>, <pgsql-patches(at)postgresql(dot)org>, "Bruce Momjian" <bruce(at)momjian(dot)us>, <heikki(at)enterprisedb(dot)com>
Subject: Re: Proposed patch - psql wraps at window width
Date: 2008-04-18 10:01:22
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-patches
"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> Bryce Nesbitt <bryce2(at)obviously(dot)com> writes:
>>     <pre wrap="">I checked the use of COLUMNS and it seems bash updates the environment
>> variable when a window is resized.
> [ Please get rid of the HTML formatting ... ]
> Bash can update the environment all it wants, but that will not affect
> what is seen by a program that's already running.  Personally I often
> resize the window while psql is running, and I expect that to work.

Hm, then having COLUMNS override the ioctl isn't such a good idea. Checking
GNU ls source the ioctl overrides COLUMNS if it works, but there's a --width
option which trumps both of the other two. I guess just a psql variable would
be the equivalent.

> I'm with Peter on this one: we have used ioctl, and nothing else, to
> determine the vertical window dimension for many years now, to the tune
> of approximately zero complaints.  It's going to take one hell of a
> strong argument to persuade me that determination of the horizontal
> dimension should not work exactly the same way.

Well the cases are not analogous. Firstly, the window height doesn't actually
alter the output. Secondly there's really no downside in a false positive
since most pagers just exit if they decide the output fit on the screen --
which probably explains why no ssh users have complained... And in any case
you can always override it by piping the output to a pager yourself -- which
is effectively all I'm suggesting doing here.

So here are your two hella-strong arguments:

a) not all terminals support the ioctl. Emacs shell users may be eccentric but
   surely using psql over ssh isn't especially uncommon. Falling back to
   COLUMNS is standard, GNU ls is not alone, Solaris and FreeBSD both document
   supporting COLUMNS.

b) you don't necessarily *want* the output formatted to fill the screen. You
   may be generating a report to email and want to set the width to the RFC
   recommended 72 characters. You may just have a full screen terminal but not
   enjoy reading 200-character long lines -- try it, it's really hard:

              If  $MANWIDTH  is  set,  its value is used as the line length for which manual pages should be formatted.  If it is not set, manual pages will be formatted with a line length appropriate to the
              current terminal (using an ioctl(2) if available, the value of $COLUMNS, or falling back to 80 characters if neither is available).  Cat pages will only be saved when the default formatting can
              be used, that is when the terminal line length is between 66 and 80 characters.

  Gregory Stark
  Ask me about EnterpriseDB's On-Demand Production Tuning

In response to

pgsql-hackers by date

Next:From: Bryce NesbittDate: 2008-04-18 14:42:13
Subject: Re: Proposed patch - psql wraps at window width
Previous:From: Gaetano MendolaDate: 2008-04-18 08:06:02
Subject: Re: new field content lost

pgsql-patches by date

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

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