Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: freebsd problems with carriage return



On Wed, 25 Mar 2009, Atom Smasher wrote:

> On Tue, 24 Mar 2009, Stephane Chazelas wrote:
> 
> > [...]
> >
> > rsync --progress /from /to | sed -n l
> >
> > (or od -c)
> >
> > to see what rsync actually outputs.
> ================
> 
> or this:
> 
> <<<<<<<<
> 
> % rsync --progress -h --bwlimit=5 ./foo_in ./foo_out > test
> 
> % cat -vet test
> foo_in$
>       32.77K   0%    0.00kB/s    0:00:00^M      65.54K   0%    5.00kB/s
> 0:49:49^M      98.30K   0%    5.00kB/s    0:49:42^M     131.07K   0% 5.00kB/s
> 0:49:36^M     163.84K   1%    5.00kB/s    0:49:29^M 196.61K   1%    5.00kB/s
> 0:49:22^M     229.38K   1%    5.00kB/s 0:49:16^M     262.14K   1%    5.00kB/s
> 0:49:09^M     294.91K   1% 5.00kB/s    0:49:03^M     327.68K   2%    5.00kB/s
> 0:48:56^M 360.45K   2%    5.00kB/s    0:48:50^M     393.22K   2%    5.00kB/s
> 0:48:43^M     425.98K   2%    5.00kB/s    0:48:36^M     458.75K   3% 5.00kB/s
> 0:48:30^M     491.52K   3%    5.00kB/s    0:48:24^M
> 	<<snip>
> 
> <<<<<<<<
> 
> all of rsync's output of interest is stdout. it's mostly a bunch of progress
> updates, separated by carriage returns.
> 

I think it's a difference in how FreeBSD and Linux handle some 
tty/job-control settings.  (Though it's not terribly surprising to me... 
one of those "I'm going to behave differently when you pipe me" things.)  
I assume your ultimate goal isn't to prepend 'foo' to each of those lines.  
What are you trying to do?

On FreeBSD for me, the status updates are visible when not piped (either 
displayed to terminal, or redirected to a file).  But, rsync --progress 
from to | cat -v only shows the final status.

I noticed in the rsync code (progress.c) that it declines to print the 
partial status lines (the ones that end with '\r' so that they can be 
overwritten) depending on the outcome of:

 210         tc_pgrp = tcgetpgrp(STDOUT_FILENO);
 211         if (tc_pgrp != pgrp && tc_pgrp != -1)
 212                 return;


I'm probably only noticing this because I just read:
"The TTY demystified"
http://www.linusakesson.net/programming/tty/index.php

Maybe something in 'stty' will affect the outcome of the above call (but 
you'd have to ask someone who knows way more about it than I do).  There 
are at least a handful of differences in the various settings between 
FreeBSD and Linux for the systems I'm using right now.

Best,
Ben



Messages sorted by: Reverse Date, Date, Thread, Author