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 200805061455.m46EtqY09102@momjian.us
Whole thread Raw
In response to Re: Proposed patch - psql wraps at window width  (Gregory Stark <stark@enterprisedb.com>)
Responses Re: Proposed patch - psql wraps at window width  (Aidan Van Dyk <aidan@highrise.ca>)
List pgsql-hackers
Gregory Stark wrote:
> "Tom Lane" <tgl@sss.pgh.pa.us> writes:
> 
> > Bruce Momjian <bruce@momjian.us> writes:
> >> Are others OK with $COLUMNS controlling screen output and file/pipe, or
> >> perhaps COLUMNS controlling only file/pipe, as GNU ls does?  I have
> >> heard a few people say they only want \pset columns to control
> >> file/pipe.
> >
> > I agree with the latter.  Anyone who is setting COLUMNS is going to set
> > it to reflect the *screen* width they want; it has zero to do with
> > what should happen for output going somewhere else than the screen.
> 
> That's just not true. Consider someone writing a cron job script who wants
> their output formatted to 72 columns. They would set COLUMNS to direct all the
> programs in the cron job script and be annoyed if some of them ignored it.
> Consider also an application like pgadmin which might want to run a script in
> a window and control how wide the output is.

Well, if they are surprised, they are easily surprised.  :-)

What logic is there that GNU ls honors COLUMNS only in non-terminal
output?  And the use of COLUMNS isn't even documented in the GNU ls
manual page.  And BSD ls honors COLUMNS only for terminal output when
the ioctl fails().  It is hard to see that there is some major
expectation of how COLUMNS should behave that would make our usage
"surprising".

If the user wants to set the wrap width for all output, they have to use
\pset columns.

Also, because we run on some platforms that don't have that ioctl(), we
are using COLUMNS as a way of providing the width only for screen
output, like iotcl() does.

> I think you need a stronger reason to disregard the user's explicit settings
> than assuming that you know what the user's planning to do with the resulting
> data. Just because the output has been redirected doesn't mean it wasn't
> redirected to something like "more" or "head" or whatever with the result
> *still* showing up on the screen.
> 
> It's one thing to change the default behaviour. It's another to disregard
> user-requested options.

We are at least correctly documenting our behavior, which is more than
the two 'ls' versions I saw did.  If users want to set something, they
better consult the documentation to find out how to do it.

--  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: Gregory Stark
Date:
Subject: Re: Proposed patch - psql wraps at window width
Next
From: Bruce Momjian
Date:
Subject: Re: Proposed patch - psql wraps at window width