Re: Proposed patch - psql wraps at window width - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: Proposed patch - psql wraps at window width
Date
Msg-id 87ej8tnqaf.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: Proposed patch - psql wraps at window width  (Bruce Momjian <bruce@momjian.us>)
Responses Re: Proposed patch - psql wraps at window width
List pgsql-hackers
[Just when I thought I was out, they pull me back in -- argh, I'm weak]

"Bruce Momjian" <bruce@momjian.us> writes:

> FYI, ls -C actually wraps to 72(?) unless you specify another width, 

I told you exactly what ls did, at least GNU ls. It uses -w if specified, if
not then it uses the ioctl if that succeeds, if it fails it uses COLUMNS, and
if that's unavailable it uses a constant.

> one possible behavior would be for \pset wrapped to wrap to 72 for
> file/pipe unless you set \pset columns.  

You can't use ls to justify having different rules for screen width for
"file/pipe":

$ COLUMNS=80 ls -C | cat
distmp3.rh3280  gconfd-stark  orbit-stark  purpleNMN49T  ssh-WdHPsk4277

$ COLUMNS=60 ls -C | cat
distmp3.rh3280  orbit-stark   ssh-WdHPsk4277
gconfd-stark    purpleNMN49T

$ COLUMNS=40 ls -C | cat
distmp3.rh3280  purpleNMN49T
gconfd-stark    ssh-WdHPsk4277
orbit-stark

$ COLUMNS=20 ls -C | cat
distmp3.rh3280
gconfd-stark
orbit-stark
purpleNMN49T
ssh-WdHPsk4277


> That might make the "I want it always to wrap" group happier, but not the
> "wrapped shouldn't affect file/pipe". I have not heard anyone explain why
> the later behavior is bad, especially if we default to a width of 72 rather
> than the screen width.

Presumably they're concerned that scripts which dump out data and then try to
parse it will have trouble parsing wrapped output. In any case that should be
based on whether isatty() is true, which is related to but not the same as
whether the window size ioctl succeeds.


--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Ask me about EnterpriseDB's Slony Replication
support!


pgsql-hackers by date:

Previous
From: Raphaël Jacquot
Date:
Subject: we don't have a bugzilla
Next
From: Bryce Nesbitt
Date:
Subject: Re: Tech details - psql wraps at window width