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

From Andrew Dunstan
Subject Re: use of pager on Windows psql
Date
Msg-id 482F5DFD.4020107@dunslane.net
Whole thread Raw
In response to Re: use of pager on Windows psql  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers

Bruce Momjian wrote:
> 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?
>   


Good point. I think the best thing would just be to remove the #ifndef 
WIN32 / #endif lines

cheers

andrew


pgsql-hackers by date:

Previous
From: "Marko Kreen"
Date:
Subject: Re: Link requirements creep
Next
From: Tom Lane
Date:
Subject: Re: windows builds hanging on regression checks