Aidan Van Dyk wrote:
> I have to admit to using the COLUMNS=... <command> trick myself.
> 
> I do have COLUMNS exported in my terminal, and often to stuff like:
> 
>       ls -C | less
> 
> and I expect it to wrap at $COLUMNS (my terminal width) in my pager.
> 
> And since the GNU coreutils is pretty consistent in this regard, I often
> export COLUMNS=<xxx> in scripts for cron jobs, reports, etc, to get
> output that formats nicely for emails, etc. 

Interesting.

> If I ever wanted the psql wrapped format, I guess *I* would hope that
> psql would work that way, simply because that's the way the other tools
> I use do it.  But I can see that if the other tools work differently,
> then there is going to have to be some people (maybe everybody) always
> double-checking the psql man page to find out again how it formats.

True.

> But since I'm not a user wanting the wrapped format, don't cater to my
> hypothetical wants.
> 
> 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.
> 
> For instance, if I was doing a query, I often to it interactively first:
>       SELECT [...] FROM [....] LIMIT 50;
> And when I'm sure I have the right values,expressions, column aliases,
> etc, I do:
>       \o /tmp/output
>       SELECT [...] FROM [...];
>       \o
> And in this case, I would expect that /tmp/output would have identical
> formatting to the LIMITed query I just ran interactively, not matter
> what setting I had for format/wrapped/auto/$COLUMNS.

The only thing we could do there perhaps is to have psql wrap file
output to the terminal width if outputting to a pipe/file, but only from
an interactive session, but that is just too odd.  If we make psql too
automatic it will be hard to explain and have more surprises.

>       `-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.

I just looked at coreutils-6.9 and 5.97 and neither manual has a mention
of COLUMNS.  Seems this is some Debian manual addition or something.  I
don't see it on Ubuntu 7.10 either.

> That's pretty straight forward, pretty explicit, and matches the
> description of what Greg has been saying all along.

Agreed.  The problem is I have a pretty even split on how this feature
should behave so we have go to with the majority and adjust as we get
feedback from the field.

-- 
  Bruce Momjian  <[EMAIL PROTECTED]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

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

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to