Re: [HACKERS] Tech details - psql wraps at window width

2008-04-26 Thread Bryce Nesbitt

Bruce Momjian wrote:
Hey, I can work with this idea. First, there really is no 'off' mode 
for wrapped because that is aligned...
Well, come to think of it, wrapped is not really a new output format 
in the sense of html or latex.  It could build on aligned:


\pset format aligned [autowrap|nowrap|nnn]

But there's still the issue of wanting separate defaults for tty and 
stream outputs.  The last thing you want is an admin deciding on 
wrapping, and then subtly breaking scripts.  My personal desired 
defaults are:


* Terminals autowrap.
* Streams don't wrap, except in the rare case when I want to force a 
specific width (e.g. 79 for a newsgroup posting).


 -Bryce



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


Re: [HACKERS] Tech details - psql wraps at window width

2008-04-26 Thread Brendan Jurd
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Sat, Apr 26, 2008 at 5:08 PM, Bryce Nesbitt
 wrote:
  Well, come to think of it, wrapped is not really a new output format in
 the sense of html or latex.  It could build on aligned:

  \pset format aligned [autowrap|nowrap|nnn]


I agree that wrapped is more a variant of aligned mode than a format
mode in its own right.  Expressing it that way with \pset has the nice
bonus that you don't lose your preference for wrapped mode when
switching between aligned and unaligned with \a.

  But there's still the issue of wanting separate defaults for tty and stream
 outputs.  The last thing you want is an admin deciding on wrapping, and then
 subtly breaking scripts.  My personal desired defaults are:


Well, if we pursue Peter's suggestion that psql abstain from reading
the startup file in noninteractive mode, then this problem goes away.
An admin could opt to wrap in his interactive sessions without it ever
affecting the behaviour of scripts ... which is exactly what you would
want.

Cheers,
BJ
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: http://getfiregpg.org

iD8DBQFIEs3x5YBsbHkuyV0RAiPsAJ0QIhWmq4s622dTZNP4MknxWTm30wCfaMTP
kY9qEW0GB3rJb3Xq5F92geY=
=GbOb
-END PGP SIGNATURE-

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


Re: [HACKERS] Tech details - psql wraps at window width

2008-04-26 Thread Bruce Momjian
Bruce Momjian wrote:
 Hey, I can work with this idea.  First, there really is no 'off' mode
 for wrapped because that is aligned.  What we could do is to have:
 
   \pset format wrapped display
 
 affect only output to the screen, using the screen width, and:
 
   \pset format wrapped nnn
 
 affect output to the screen and file/pipes.

A new idea would be for a wrap value of zero to be special:

\pset format wrapped 0
 
to wrap to screen width for terminal and file/pipe output.

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


[HACKERS] Tech details - psql wraps at window width

2008-04-25 Thread Bryce Nesbitt
As the originator of the psql wraps at window width patch, I'd like to 
set a matter or two straight:


The ioctl() function does not fail under ssh, contrary to the assertion 
made several times.  Nor does $COLUMNS remain static if the window size 
changes.  $COLUMNS is not a property of a bash, you'll find it is set by 
the readline library.  $COLUMNS is not fully cross-platform, though 
$MANWIDTH should be fine.  Please supply counter examples if needed, but 
this is pretty well traveled ground.  I think the original patch is fat 
and happy as far as interactive terminal use.


But I agree it's not desirable to wrap file any sort of stream output, 
by default, as that would break just about any script known to mankind.  
Yet wrapping is a very user-friendly default for interactive terminals. 
This is potentially an irreconcilable inconsistency.


I weigh in on the side of leaving it inconsistent, but making it really 
easy to force the behavior you want with something like:

  \pset format wrap [auto|nnn|off]

But that leaves a big hole: what does the setting in .psqlrc refer to?  
Do we need separate controls in .psql?


  \pset format_terminal wrap [auto|nnn|off]
  \pset format_terminal html
  \pset format_stream wrap [auto|nnn|off]
  \pset format_stream html

Where, on a stream, auto and off would have the same meaning, and \pset 
format would set both?



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


Re: [HACKERS] Tech details - psql wraps at window width

2008-04-25 Thread Peter Eisentraut
Am Samstag, 26. April 2008 schrieb Bryce Nesbitt:
 But that leaves a big hole: what does the setting in .psqlrc refer to?  
 Do we need separate controls in .psql?

    \pset format_terminal wrap [auto|nnn|off]
    \pset format_terminal html
    \pset format_stream wrap [auto|nnn|off]
    \pset format_stream html

I think one of the weirdest behaviors in psql is that it reads the startup 
file in noninteractive mode.  Unix shells don't do this for good reasons.  If 
we could work out a change that moves the psql startup file behavior more in 
line with that of Unix shells, perhaps meaning separate startup files, then 
users could put all the crazy formatting settings they like in .psqlrc 
without affecting noninteractive output.  And there would still be the 
possibility to format noninteractive output the way you want by explicit 
intervention.  This is basically what your pseudoproposal above would 
accomplish, just on a more global scale.

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


Re: [HACKERS] Tech details - psql wraps at window width

2008-04-25 Thread Bruce Momjian
Bryce Nesbitt wrote:
 But I agree it's not desirable to wrap file any sort of stream output, 
 by default, as that would break just about any script known to mankind.  
 Yet wrapping is a very user-friendly default for interactive terminals. 
 This is potentially an irreconcilable inconsistency.
 
 I weigh in on the side of leaving it inconsistent, but making it really 
 easy to force the behavior you want with something like:
\pset format wrap [auto|nnn|off]
 
 But that leaves a big hole: what does the setting in .psqlrc refer to?  
 Do we need separate controls in .psql?
 
\pset format_terminal wrap [auto|nnn|off]
\pset format_terminal html
\pset format_stream wrap [auto|nnn|off]
\pset format_stream html
 
 Where, on a stream, auto and off would have the same meaning, and \pset 
 format would set both?

Hey, I can work with this idea.  First, there really is no 'off' mode
for wrapped because that is aligned.  What we could do is to have:

\pset format wrapped display

affect only output to the screen, using the screen width, and:

\pset format wrapped nnn

affect output to the screen and file/pipes.

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