Re: [HACKERS] pg_basebackup --progress output for batch execution

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Martín Marqués <martin(at)2ndquadrant(dot)com>, Arthur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] pg_basebackup --progress output for batch execution
Date: 2017-12-01 14:28:08
Message-ID: 427fd057-e592-f1b1-77fe-a60fbaf5694f@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/21/17 05:16, Martín Marqués wrote:
> El 21/11/17 a las 04:56, Arthur Zakirov escribió:
>> On Mon, Nov 20, 2017 at 04:45:48PM -0300, Martín Marqués wrote:
>>> New version of patch, without the --batch-mode option and using isatty()
>>>
>>
>> Great!
>>
>>> + fprintf(stderr, "waiting for checkpoint");
>>> + if (isatty(fileno(stderr)))
>>> + fprintf(stderr, "\n");
>>> + else
>>> + fprintf(stderr, "\r");
>>
>> Here the condition should be inverted I think. The next condition should be used:
>>
>>> if (!isatty(fileno(stderr)))
>>> ...
>>
>> Otherwise pg_basebackup will insert '\n' in terminal instead '\r'.
>
> Ups! Attached the corrected version.:)
>
> Nice catch. I completely missed that. Thanks.

Committed.

I switched the if logic around even more, so that it is

! if (isatty(fileno(stderr)))
! fprintf(stderr, "\r");
! else
! fprintf(stderr, "\n");

instead of

! if (!isatty(fileno(stderr)))
! fprintf(stderr, "\n");
! else
! fprintf(stderr, "\r");

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2017-12-01 14:31:32 Re: [HACKERS] SQL procedures
Previous Message Robert Haas 2017-12-01 14:23:07 Re: [HACKERS] Custom compression methods