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 { (p)->curfile = NULL; \ } while (0) void bb_progress_init(bb_progress_t *p, const char *curfile) FAST_FUNC; -void bb_progress_update(bb_progress_t *p, +int bb_progress_update(bb_progress_t *p, uoff_t beg_range, uoff_t transferred, 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) * will be "totalsize" bytes. * If totalsize == 0, then it is unknown. */ -void FAST_FUNC bb_progress_update(bb_progress_t *p, +int FAST_FUNC bb_progress_update(bb_progress_t *p, uoff_t beg_size, uoff_t transferred, uoff_t totalsize) @@ -94,7 +94,7 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p, * Do not update on every call * (we can be called on every network read!) */ - return; + return -1; } /* 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, } if (notty) fputc('\n', stderr); + return notty; } 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 { #if ENABLE_FEATURE_WGET_STATUSBAR static void progress_meter(int flag) { + int notty; + if (option_mask32 & WGET_OPT_QUIET) return; if (flag == PROGRESS_START) bb_progress_init(&G.pmt, G.curfile); - bb_progress_update(&G.pmt, + notty = bb_progress_update(&G.pmt, G.beg_range, G.transferred, (G.chunked || !G.got_clen) ? 0 : G.beg_range + G.transferred + G.content_len @@ -297,7 +299,8 @@ static void progress_meter(int flag) if (flag == PROGRESS_END) { bb_progress_free(&G.pmt); - bb_putchar_stderr('\n'); + if (notty == 0) + bb_putchar_stderr('\n'); /* it's tty */ G.transferred = 0; } }