xbps-install: fetch_cb.c: if stdout is a tty use stderr.

This commit is contained in:
Juan RP 2012-12-10 11:20:59 +01:00
parent ca5aeebdc9
commit f2d2b2fde9

View File

@ -145,7 +145,7 @@ stat_display(struct xbps_fetch_cb_data *xfpd, void *cbdata)
(void)xbps_humanize_number(totsize, (int64_t)xfpd->file_size);
}
if (isatty(fileno(stdout)))
printf("%s: [%s %d%%] %s ETA: %s\033[K\r",
fprintf(stderr, "%s: [%s %d%%] %s ETA: %s\033[K\r",
xfpd->file_name, totsize, percentage,
stat_bps(xfpd, xfer), stat_eta(xfpd, xfer));
else
@ -171,7 +171,7 @@ fetch_file_progress_cb(struct xbps_fetch_cb_data *xfpd, void *cbdata)
/* end transfer stats */
(void)xbps_humanize_number(size, (int64_t)xfpd->file_dloaded);
if (isatty(fileno(stdout)))
printf("%s: %s [avg rate: %s]\033[K\n",
fprintf(stderr, "%s: %s [avg rate: %s]\033[K\n",
xfpd->file_name, size, stat_bps(xfpd, xfer));
else
printf("%s: %s [avg rate: %s]\n",