aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-23 02:01:38 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-23 02:01:38 +0200
commitd3d6534b2a86bdd651aa39dfabe620fe2208459f (patch)
tree78f077b5f383ff9c3f5b0b59e3b33d52055cc409
parent641caaec3d495f3a92f652f12ab70b02ba9312ac (diff)
downloadbusybox-w32-d3d6534b2a86bdd651aa39dfabe620fe2208459f.tar.gz
busybox-w32-d3d6534b2a86bdd651aa39dfabe620fe2208459f.tar.bz2
busybox-w32-d3d6534b2a86bdd651aa39dfabe620fe2208459f.zip
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>
-rw-r--r--libbb/progress.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libbb/progress.c b/libbb/progress.c
index 6154dca17..3c2f01667 100644
--- a/libbb/progress.c
+++ b/libbb/progress.c
@@ -73,7 +73,7 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
73{ 73{
74 uoff_t beg_and_transferred; 74 uoff_t beg_and_transferred;
75 unsigned since_last_update, elapsed; 75 unsigned since_last_update, elapsed;
76 int barlength; 76 int notty;
77 int kiloscale; 77 int kiloscale;
78 78
79 //transferred = 1234; /* use for stall detection testing */ 79 //transferred = 1234; /* use for stall detection testing */
@@ -130,14 +130,17 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
130 } 130 }
131 } 131 }
132 132
133 notty = !isatty(STDERR_FILENO);
134
133 if (ENABLE_UNICODE_SUPPORT) 135 if (ENABLE_UNICODE_SUPPORT)
134 fprintf(stderr, "\r%s", p->curfile); 136 fprintf(stderr, "\r%s" + notty, p->curfile);
135 else 137 else
136 fprintf(stderr, "\r%-20.20s", p->curfile); 138 fprintf(stderr, "\r%-20.20s" + notty, p->curfile);
137 139
138 beg_and_transferred = beg_size + transferred; 140 beg_and_transferred = beg_size + transferred;
139 141
140 if (totalsize != 0) { 142 if (totalsize != 0) {
143 int barlength;
141 unsigned ratio = 100 * beg_and_transferred / totalsize; 144 unsigned ratio = 100 * beg_and_transferred / totalsize;
142 fprintf(stderr, "%4u%%", ratio); 145 fprintf(stderr, "%4u%%", ratio);
143 146
@@ -197,4 +200,6 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
197 hours = eta / 3600; 200 hours = eta / 3600;
198 fprintf(stderr, "%3u:%02u:%02u ETA", hours, secs / 60, secs % 60); 201 fprintf(stderr, "%3u:%02u:%02u ETA", hours, secs / 60, secs % 60);
199 } 202 }
203 if (notty)
204 fputc('\n', stderr);
200} 205}