summaryrefslogtreecommitdiff
path: root/libbb/progress.c
diff options
context:
space:
mode:
authorDenys Vlasenko2015-10-23 02:01:38 +0200
committerDenys Vlasenko2015-10-23 02:01:38 +0200
commitd3d6534b2a86bdd651aa39dfabe620fe2208459f (patch)
tree78f077b5f383ff9c3f5b0b59e3b33d52055cc409 /libbb/progress.c
parent641caaec3d495f3a92f652f12ab70b02ba9312ac (diff)
downloadbusybox-d3d6534b2a86bdd651aa39dfabe620fe2208459f.zip
busybox-d3d6534b2a86bdd651aa39dfabe620fe2208459f.tar.gz
wget: if stderr is not a tty, progress bar shouldn't use tty-tricks
function old new delta bb_progress_update 706 768 +62 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/progress.c')
-rw-r--r--libbb/progress.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libbb/progress.c b/libbb/progress.c
index 6154dca..3c2f016 100644
--- a/libbb/progress.c
+++ b/libbb/progress.c
@@ -73,7 +73,7 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
{
uoff_t beg_and_transferred;
unsigned since_last_update, elapsed;
- int barlength;
+ int notty;
int kiloscale;
//transferred = 1234; /* use for stall detection testing */
@@ -130,14 +130,17 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
}
}
+ notty = !isatty(STDERR_FILENO);
+
if (ENABLE_UNICODE_SUPPORT)
- fprintf(stderr, "\r%s", p->curfile);
+ fprintf(stderr, "\r%s" + notty, p->curfile);
else
- fprintf(stderr, "\r%-20.20s", p->curfile);
+ fprintf(stderr, "\r%-20.20s" + notty, p->curfile);
beg_and_transferred = beg_size + transferred;
if (totalsize != 0) {
+ int barlength;
unsigned ratio = 100 * beg_and_transferred / totalsize;
fprintf(stderr, "%4u%%", ratio);
@@ -197,4 +200,6 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
hours = eta / 3600;
fprintf(stderr, "%3u:%02u:%02u ETA", hours, secs / 60, secs % 60);
}
+ if (notty)
+ fputc('\n', stderr);
}