diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2017-12-01 09:21:34 -0500 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2017-12-01 09:21:34 -0500 |
commit | 143b54d21d37804707c27edebdbd4410891da133 (patch) | |
tree | 43527030401a5a887e903d024f4b1d3137222bc1 /src | |
parent | 06ae669c9229270663d6c4953ceb3621e4bc2d5b (diff) | |
download | postgresql-143b54d21d37804707c27edebdbd4410891da133.tar.gz postgresql-143b54d21d37804707c27edebdbd4410891da133.zip |
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: Arthur Zakirov <a.zakirov@postgrespro.ru>
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_basebackup/pg_basebackup.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 8427c97fe4a..4fbca7d8e88 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -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); |