Re: Proposed patch - psql wraps at window width

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Brendan Jurd <direvus(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bryce Nesbitt <bryce2(at)obviously(dot)com>, heikki(at)enterprisedb(dot)com
Subject: Re: Proposed patch - psql wraps at window width
Date: 2008-04-26 13:33:17
Message-ID: 200804261333.m3QDXHv16131@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gregory Stark wrote:
>
> [Just when I thought I was out, they pull me back in -- argh, I'm weak]
>
> "Bruce Momjian" <bruce(at)momjian(dot)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.

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

I don't see that behavior here on Ubuntu 7.10:

$ COLUMNNS=120 ls -C |cat
archive cd initrd lost+found proc srv usr
basement.usr dev initrd.img media root sys var
bin etc laptop mnt rtmp tmp vmlinuz
boot home lib opt sbin u win
$ ls --version
ls (GNU coreutils) 5.97

That is not a 120 width. 'ls' seems to ignore columns for pipe output.

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

Right now we honor $COLUMNS only when isatty() is true.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2008-04-26 13:36:44 Re: Tech details - psql wraps at window width
Previous Message Robert Treat 2008-04-26 13:10:53 Re: Re: [HACKERS] [COMMITTERS] pgsql: Fix TransactionIdIsCurrentTransactionId() to use binary search