wget: print the final newline only for non-tty output
$ busybox wget URL 2>&1 | cat Connecting to .... install.iso 0% | | 2629k 0:02:05 ETA install.iso 7% |** | 25.7M 0:00:23 ETA install.iso 16% |***** | 54.1M 0:00:14 ETA install.iso 20% |****** | 67.4M 0:00:15 ETA install.iso 25% |******** | 81.0M 0:00:14 ETA install.iso 30% |********* | 97.3M 0:00:13 ETA install.iso 36% |*********** | 117M 0:00:12 ETA install.iso 41% |************* | 134M 0:00:11 ETA install.iso 47% |*************** | 152M 0:00:10 ETA install.iso 54% |***************** | 176M 0:00:08 ETA install.iso 61% |******************* | 200M 0:00:06 ETA install.iso 66% |********************* | 215M 0:00:06 ETA install.iso 71% |********************** | 231M 0:00:05 ETA install.iso 75% |************************ | 244M 0:00:04 ETA install.iso 79% |************************* | 257M 0:00:03 ETA install.iso 84% |*************************** | 275M 0:00:02 ETA install.iso 91% |***************************** | 297M 0:00:01 ETA install.iso 99% |******************************* | 321M 0:00:00 ETA install.iso 100% |********************************| 323M 0:00:00 ETA <-- no empty line here $ function old new delta bb_progress_update 622 632 +10 progress_meter 152 158 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 16/0) Total: 16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
fbf5e6363b
commit
26602b85a3
@ -2007,7 +2007,7 @@ typedef struct bb_progress_t {
|
|||||||
(p)->curfile = NULL; \
|
(p)->curfile = NULL; \
|
||||||
} while (0)
|
} while (0)
|
||||||
void bb_progress_init(bb_progress_t *p, const char *curfile) FAST_FUNC;
|
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 beg_range,
|
||||||
uoff_t transferred,
|
uoff_t transferred,
|
||||||
uoff_t totalsize) FAST_FUNC;
|
uoff_t totalsize) FAST_FUNC;
|
||||||
|
@ -69,7 +69,7 @@ void FAST_FUNC bb_progress_init(bb_progress_t *p, const char *curfile)
|
|||||||
* will be "totalsize" bytes.
|
* will be "totalsize" bytes.
|
||||||
* If totalsize == 0, then it is unknown.
|
* 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 beg_size,
|
||||||
uoff_t transferred,
|
uoff_t transferred,
|
||||||
uoff_t totalsize)
|
uoff_t totalsize)
|
||||||
@ -94,7 +94,7 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
|
|||||||
* Do not update on every call
|
* Do not update on every call
|
||||||
* (we can be called on every network read!)
|
* (we can be called on every network read!)
|
||||||
*/
|
*/
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Before we lose real, unscaled sizes, produce human-readable size string */
|
/* 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)
|
if (notty)
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
|
return notty;
|
||||||
}
|
}
|
||||||
|
@ -283,13 +283,15 @@ enum {
|
|||||||
#if ENABLE_FEATURE_WGET_STATUSBAR
|
#if ENABLE_FEATURE_WGET_STATUSBAR
|
||||||
static void progress_meter(int flag)
|
static void progress_meter(int flag)
|
||||||
{
|
{
|
||||||
|
int notty;
|
||||||
|
|
||||||
if (option_mask32 & WGET_OPT_QUIET)
|
if (option_mask32 & WGET_OPT_QUIET)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (flag == PROGRESS_START)
|
if (flag == PROGRESS_START)
|
||||||
bb_progress_init(&G.pmt, G.curfile);
|
bb_progress_init(&G.pmt, G.curfile);
|
||||||
|
|
||||||
bb_progress_update(&G.pmt,
|
notty = bb_progress_update(&G.pmt,
|
||||||
G.beg_range,
|
G.beg_range,
|
||||||
G.transferred,
|
G.transferred,
|
||||||
(G.chunked || !G.got_clen) ? 0 : G.beg_range + G.transferred + G.content_len
|
(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) {
|
if (flag == PROGRESS_END) {
|
||||||
bb_progress_free(&G.pmt);
|
bb_progress_free(&G.pmt);
|
||||||
bb_putchar_stderr('\n');
|
if (notty == 0)
|
||||||
|
bb_putchar_stderr('\n'); /* it's tty */
|
||||||
G.transferred = 0;
|
G.transferred = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user