Re: Proposed patch - psql wraps at window width

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Bruce Momjian" <bruce(at)momjian(dot)us>
Cc: "Brendan Jurd" <direvus(at)gmail(dot)com>, "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>, "Bryce Nesbitt" <bryce2(at)obviously(dot)com>, <heikki(at)enterprisedb(dot)com>
Subject: Re: Proposed patch - psql wraps at window width
Date: 2008-04-24 18:58:20
Message-ID: 87hcdr6pwz.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

"Bruce Momjian" <bruce(at)momjian(dot)us> writes:

> 'ls' and 'ls | more' generate different outputs, and I have never heard
> anyone call that "bunk".

The analogue of that would be making psql default to wrapped mode if isatty is
true and normal mode if it's false. I wouldn't be entirely against that but I
don't really care much either way.

Note that there's still -C and -1 to override that default. And if you specify
-C or isatty returns true it *always* uses the same deterministic logic to
determine the width: -w first, then ioctl, then COLUMNS.

> Also, this does work:
>
> psql -Pformat=wrapped -Pcolumns=70 -c "select repeat('a', 100)" test | more
>
> If you want non-terminal output to wrap, you have to specify the width
> --- that seems only reasonable because the file case really needs to
> have the width specified.

No it's not reasonable. I promise you users will report this as a bug.

This isn't anything new. Offhand I could only think of two precedents, ls and
man, but I'm sure there are others. They both use the same basic logic. And
not just GNU, FreeBSD and Solaris document the same behaviour.

I'm puzzled what you think should happen for the above. You think it should
just ignore the user's -Pformat=wrapped ?

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's RemoteDBA services!

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2008-04-24 19:22:16 Re: Proposed patch - psql wraps at window width
Previous Message Aidan Van Dyk 2008-04-24 18:46:16 Re: Proposed patch - psql wraps at window width

Browse pgsql-patches by date

  From Date Subject
Next Message Brendan Jurd 2008-04-24 19:07:18 ADD COLUMN with PRIMARY KEY bug (was: I think this is a BUG?)
Previous Message Aidan Van Dyk 2008-04-24 18:46:16 Re: Proposed patch - psql wraps at window width