Re: use of pager on Windows psql

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

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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Kreen 2008-05-17 22:04:40 Re: Link requirements creep
Previous Message Tom Lane 2008-05-17 21:40:13 Link requirements creep

Browse pgsql-patches by date

  From Date Subject
Next Message Euler Taveira de Oliveira 2008-05-17 21:55:27 Re: pg_dump lock timeout - resend
Previous Message Bruce Momjian 2008-05-17 21:27:42 Re: [COMMITTERS] pgsql: Don't call rm with empty file list.