aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libbb.h2
-rw-r--r--libbb/progress.c5
-rw-r--r--networking/wget.c7
3 files changed, 9 insertions, 5 deletions
diff --git a/include/libbb.h b/include/libbb.h
index b041ce047..883457c0d 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -2007,7 +2007,7 @@ typedef struct bb_progress_t {
2007 (p)->curfile = NULL; \ 2007 (p)->curfile = NULL; \
2008} while (0) 2008} while (0)
2009void bb_progress_init(bb_progress_t *p, const char *curfile) FAST_FUNC; 2009void bb_progress_init(bb_progress_t *p, const char *curfile) FAST_FUNC;
2010void bb_progress_update(bb_progress_t *p, 2010int bb_progress_update(bb_progress_t *p,
2011 uoff_t beg_range, 2011 uoff_t beg_range,
2012 uoff_t transferred, 2012 uoff_t transferred,
2013 uoff_t totalsize) FAST_FUNC; 2013 uoff_t totalsize) FAST_FUNC;
diff --git a/libbb/progress.c b/libbb/progress.c
index 23e974ce7..d071ce705 100644
--- a/libbb/progress.c
+++ b/libbb/progress.c
@@ -69,7 +69,7 @@ void FAST_FUNC bb_progress_init(bb_progress_t *p, const char *curfile)
69 * will be "totalsize" bytes. 69 * will be "totalsize" bytes.
70 * If totalsize == 0, then it is unknown. 70 * If totalsize == 0, then it is unknown.
71 */ 71 */
72void FAST_FUNC bb_progress_update(bb_progress_t *p, 72int FAST_FUNC bb_progress_update(bb_progress_t *p,
73 uoff_t beg_size, 73 uoff_t beg_size,
74 uoff_t transferred, 74 uoff_t transferred,
75 uoff_t totalsize) 75 uoff_t totalsize)
@@ -94,7 +94,7 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
94 * Do not update on every call 94 * Do not update on every call
95 * (we can be called on every network read!) 95 * (we can be called on every network read!)
96 */ 96 */
97 return; 97 return -1;
98 } 98 }
99 99
100 /* Before we lose real, unscaled sizes, produce human-readable size string */ 100 /* Before we lose real, unscaled sizes, produce human-readable size string */
@@ -211,4 +211,5 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
211 } 211 }
212 if (notty) 212 if (notty)
213 fputc('\n', stderr); 213 fputc('\n', stderr);
214 return notty;
214} 215}
diff --git a/networking/wget.c b/networking/wget.c
index 65262e19d..44c481a99 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -283,13 +283,15 @@ enum {
283#if ENABLE_FEATURE_WGET_STATUSBAR 283#if ENABLE_FEATURE_WGET_STATUSBAR
284static void progress_meter(int flag) 284static void progress_meter(int flag)
285{ 285{
286 int notty;
287
286 if (option_mask32 & WGET_OPT_QUIET) 288 if (option_mask32 & WGET_OPT_QUIET)
287 return; 289 return;
288 290
289 if (flag == PROGRESS_START) 291 if (flag == PROGRESS_START)
290 bb_progress_init(&G.pmt, G.curfile); 292 bb_progress_init(&G.pmt, G.curfile);
291 293
292 bb_progress_update(&G.pmt, 294 notty = bb_progress_update(&G.pmt,
293 G.beg_range, 295 G.beg_range,
294 G.transferred, 296 G.transferred,
295 (G.chunked || !G.got_clen) ? 0 : G.beg_range + G.transferred + G.content_len 297 (G.chunked || !G.got_clen) ? 0 : G.beg_range + G.transferred + G.content_len
@@ -297,7 +299,8 @@ static void progress_meter(int flag)
297 299
298 if (flag == PROGRESS_END) { 300 if (flag == PROGRESS_END) {
299 bb_progress_free(&G.pmt); 301 bb_progress_free(&G.pmt);
300 bb_putchar_stderr('\n'); 302 if (notty == 0)
303 bb_putchar_stderr('\n'); /* it's tty */
301 G.transferred = 0; 304 G.transferred = 0;
302 } 305 }
303} 306}