Bryce Nesbitt wrote:
> 
> > OK, so COLUMNS should take precedence.  I assume this is going to
> > require us to read the COLUMNS environment variable in psql _before_
> > readline sets it, and that COLUMNS will only affect screen output, like
> > ioctl().  Is that consistent?
> >   
> This whole thing is confusing enough at the point, I think a complete 
> proposal needs to be articulated. It is hard to comment on a fragment of 
> an idea.
> 
> The main cases to cover are:  (1) how to specify wrap for tty's

In order of precedence:

        \pset columns
        $COLUMNS
        iotcl()

>  (2) how to specify wrap for pipes

        \pset columns

> (3) how to get wrapped on platforms that don't 
> have the ioctl (presumably windows without cygwin)   

        \pset columns
        $COLUMNS

> (4) how to set up 
> different defaults for tty's and pipes (e.g. wrap interactive tty's, but 
> leave output aligned for scripts).
> 
> And perhaps, as a bonus comment on (5) the idea of having psql NOT 
> source .psqlrc

       -X
       --no-psqlrc

> I hope at some point someone will actually try the actual core wrapping 
> code, and comment on it.

I tested it and it worked well once I modified it.

Updated patch with clearer documentation that matches the above
behavior:

        ftp://momjian.us/pub/postgresql/mypatches/wrap

FYI, I looked into 'ls -C' hanlding a little more and ls (GNU coreutils)
5.97 honors COLUMNS _only_ in file/pipe output, not for screen output. 
What the C code does is to read COLUMNS, then overwrite that value with
ioctl() if it works.

Do we want to follow that behavior?  ls has a '-w' option to specify the
width, like our \pset columns.  However, the manual page seems backwards:

       -w, --width=COLS
              assume screen width instead of current value

The GNU 'ls' manual does not mention COLUMNS.

BSD 'ls' used COLUMNS only when outputing to the screen, and ioctl
fails.  However, the BSD manual says:

     COLUMNS    If this variable contains a string representing a decimal
                integer, it is used as the column position width for
                displaying multiple-text-column output.  The ls utility
                calculates how many pathname text columns to display based
                on the width pro- vided.  (See -C.)

Again, I think the manual is wrong.

So it seem GNU ls and BSD ls are inconsistent, which I think means we
should design our API the best we can, rather than rely on how others
interpret COLUMNS.

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