Re: use of pager on Windows psql - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: use of pager on Windows psql
Date
Msg-id 200805172146.m4HLk4k28052@momjian.us
Whole thread Raw
In response to use of pager on Windows psql  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: use of pager on Windows psql  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Andrew Dunstan wrote:
> 
> psql's print.c contains this piece of code:
> 
> /*
>  * PageOutput
>  *
>  * Tests if pager is needed and returns appropriate FILE pointer.
>  */
> FILE *
> PageOutput(int lines, unsigned short int pager)
> {
>     /* check whether we need / can / are supposed to use pager */
>     if (pager
> #ifndef WIN32
>         &&
>         isatty(fileno(stdin)) &&
>         isatty(fileno(stdout))
> #endif
>         )
>     {
> 
> 
> 
> Why are we not doing the isatty tests on Windows? We can and do use 
> isatty on Windows elsewhere, so I'm a bit mystified about this.

Not sure why ware are not.  Should we enabled that code on Win32 and see
how it works?  Can you test it? Was it some MinGW limitation?  I do see
isatty() being used on lots of platforms.

This is kind of odd.  Ah, I bet it came from libpq's PQprint(), which I
think we had working on Win32 long before we had psql working and
perhaps I copied it from there.  I don't see the Win32 checks around
isatty() anywhere else.

> In fact, it looks to me like it would be much more sensible to #include 
> "settings.h" and then simply test pset.notty for all platforms.

Yes, we could do that but does the isatty() value ever change while psql
is running?  When you do '\g filename' does stdout then have isatty as
false?

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Link requirements creep
Next
From: "Marko Kreen"
Date:
Subject: Re: Link requirements creep