Re: use of pager on Windows psql

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: use of pager on Windows psql
Date: 2008-05-17 22:36:45
Message-ID: 482F5DFD.4020107@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-05-17 23:23:20 Re: windows builds hanging on regression checks
Previous Message Marko Kreen 2008-05-17 22:04:40 Re: Link requirements creep

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2008-05-17 22:52:54 Re: psql command aliases support
Previous Message Euler Taveira de Oliveira 2008-05-17 21:55:27 Re: pg_dump lock timeout - resend