Re: Progress reporting for pg_verify_checksums

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Progress reporting for pg_verify_checksums
Дата
Msg-id 20181226024509.jokvzsbmgwjacvce@alvherre.pgsql
обсуждение исходный текст
Ответ на Re: Progress reporting for pg_verify_checksums  (Michael Paquier <michael@paquier.xyz>)
Ответы Re: Progress reporting for pg_verify_checksums  (Michael Paquier <michael@paquier.xyz>)
Список 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 по дате отправления:

Предыдущее
От: "Nagaura, Ryohei"
Дата:
Сообщение: RE: Timeout parameters
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Feature: triggers on materialized views