Re: Progress reporting for pg_verify_checksums - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Progress reporting for pg_verify_checksums
Date
Msg-id 20181226024509.jokvzsbmgwjacvce@alvherre.pgsql
Whole thread Raw
In response to Re: Progress reporting for pg_verify_checksums  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Progress reporting for pg_verify_checksums
List pgsql-hackers
On 2018-Dec-26, Michael Paquier wrote:

> +   /*
> +    * If we are reporting to a terminal, send a carriage return so that we
> +    * stay on the same line.  If not, send a newline.
> +    */
> +   if (isatty(fileno(stderr)))
> +       fprintf(stderr, "\r");
> +   else
> +       fprintf(stderr, "\n");
> This bit is not really elegant, why not just '\r'?

Umm, this is established coding pattern in pg_basebackup.c.
Stylistically I'd change all those cases to "fprintf(stderr,
isatty(fileno(stderr)) ? "\r" : "\n")" but leave the string alone, since
AFAIR it took some time to figure out what to do.  (I'd also make the
comment one line instead of four, say "Stay on the same line if
reporting to a terminal".  That makes the whole stanza two lines rather
than eight, which is the appropriate amount of space for it).

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-hackers by date:

Previous
From: "Nagaura, Ryohei"
Date:
Subject: RE: Timeout parameters
Next
From: Alvaro Herrera
Date:
Subject: Re: Feature: triggers on materialized views