diff options
author | jmg <jmg@FreeBSD.org> | 1997-02-17 04:11:47 +0000 |
---|---|---|
committer | jmg <jmg@FreeBSD.org> | 1997-02-17 04:11:47 +0000 |
commit | dfdb961559a9468bc673f758c2b1f4238638fb6d (patch) | |
tree | 5ac71802b70645958aabd5641966982e787f966b /usr.bin | |
parent | 628ea945c27250b30d214b04140bf0b4257eb701 (diff) | |
download | FreeBSD-src-dfdb961559a9468bc673f758c2b1f4238638fb6d.zip FreeBSD-src-dfdb961559a9468bc673f758c2b1f4238638fb6d.tar.gz |
Fix fetch so that all status information is sent to stderr, prevents
corruption of file being recieved to stdout.
Submitted-by: Kent Vander Velden <graphix@iastate.edu>
Closes PR#2739
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/fetch/main.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/usr.bin/fetch/main.c b/usr.bin/fetch/main.c index 57f1d40..5a457cd 100644 --- a/usr.bin/fetch/main.c +++ b/usr.bin/fetch/main.c @@ -308,8 +308,7 @@ display(struct fetch_state *fs, off_t size, ssize_t n) size ? "" : " [appending]"); else asprintf (&s, "Receiving %s", fs->fs_outputfile); - printf ("%s", s); - fflush (stdout); + fprintf (stderr, "%s", s); bytestart = bytes = n; return; } @@ -317,19 +316,20 @@ display(struct fetch_state *fs, off_t size, ssize_t n) if (n == -1) { if(stdoutatty) { if (size > 0) - printf ("\r%s: 100%%", s); + fprintf (stderr, "\r%s: 100%%", s); else - printf ("\r%s: %qd Kbytes", s, (quad_t)bytes/1024); + fprintf (stderr, "\r%s: %qd Kbytes", s, (quad_t)bytes/1024); } bytes -= bytestart; d = t.tv_sec + t.tv_usec/1.e6 - t_start.tv_sec - t_start.tv_usec/1.e6; - printf ("\n%qd bytes transfered in %.1f seconds", (quad_t)bytes, d); + fprintf (stderr, "\n%qd bytes transfered in %.1f seconds", + (quad_t)bytes, d); d = bytes/d; if (d < 1000) - printf (" (%.0f bytes/s)\n", d); + fprintf (stderr, " (%.0f bytes/s)\n", d); else { d /=1024; - printf (" (%.2f kB/s)\n", d); + fprintf (stderr, " (%.2f kB/s)\n", d); } free(s); init = 0; @@ -343,12 +343,11 @@ display(struct fetch_state *fs, off_t size, ssize_t n) pr++; if(stdoutatty) { if (size > 1000000) - printf ("\r%s: %2qd%%", s, (quad_t)bytes/(size/100)); + fprintf (stderr, "\r%s: %2qd%%", s, (quad_t)bytes/(size/100)); else if (size > 0) - printf ("\r%s: %2qd%%", s, (quad_t)100*bytes/size); + fprintf (stderr, "\r%s: %2qd%%", s, (quad_t)100*bytes/size); else - printf ("\r%s: %qd kB", s, (quad_t)bytes/1024); + fprintf (stderr, "\r%s: %qd kB", s, (quad_t)bytes/1024); } - fflush (stdout); } |