Commit 143b54d2 authored by Peter Eisentraut's avatar Peter Eisentraut

pg_basebackup: Fix progress messages when writing to a file

The progress messages print out \r to keep overwriting the same line on
the screen.  But this does not yield useful results when writing the
output to a file.  So in that case, print out \n instead.

Author: Martín Marqués <martin@2ndquadrant.com>
Reviewed-by: default avatarArthur Zakirov <a.zakirov@postgrespro.ru>
parent 06ae669c
......@@ -811,7 +811,10 @@ progress_report(int tablespacenum, const char *filename, bool force)
totaldone_str, totalsize_str, percent,
tablespacenum, tablespacecount);
fprintf(stderr, "\r");
if (isatty(fileno(stderr)))
fprintf(stderr, "\r");
else
fprintf(stderr, "\n");
}
static int32
......@@ -1796,7 +1799,13 @@ BaseBackup(void)
progname);
if (showprogress && !verbose)
fprintf(stderr, "waiting for checkpoint\r");
{
fprintf(stderr, "waiting for checkpoint");
if (isatty(fileno(stderr)))
fprintf(stderr, "\r");
else
fprintf(stderr, "\n");
}
basebkp =
psprintf("BASE_BACKUP LABEL '%s' %s %s %s %s %s %s",
......@@ -1929,7 +1938,8 @@ BaseBackup(void)
if (showprogress)
{
progress_report(PQntuples(res), NULL, true);
fprintf(stderr, "\n"); /* Need to move to next line */
if (isatty(fileno(stderr)))
fprintf(stderr, "\n"); /* Need to move to next line */
}
PQclear(res);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment