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

Re: freebsd problems with carriage return



2009-03-25 10:36:21 +1300, Atom Smasher:
> On Tue, 24 Mar 2009, Stephane Chazelas wrote:
>
>> 2009-03-24 23:14:09 +1300, Atom Smasher:
>>> on linux this works as expected:
>>>
>>>      rsync --progress /from /to | while read -d "`print '\r'`" n
>>
>> See $'\r' instead of "`print '\r'`"
>>
>>>      do
>>>          print "  foo: $n"
>>
>> should be print -r, print without -r expands the \ sequences.
>>
>> You should probably use IFS= read -r instead of read as well.
> =================
>
> huh?
>
> here are screen-shots of what it's doing on linux, which is what i expect 
> and desire:
> 	http://smasher.org/tmp/snapshot149.png
> 	http://smasher.org/tmp/snapshot150.png
>
> here's a screen-shot of modifying IFS, which i almost thought would work, 

Sorry for the confusion, this was a remark on your code. I was
not suggesting that it was a fix for your problem.

read without -r processes the backslashes in its input
specially, so you generally need to pass it especially in
scripts.

Same, if you don't remove the white space characters from IFS,
read strips the leading and trailing ones.

$ print '  \\a \rb' | read -d $'\r' a; print -r "$a" | cat -vte
a$
$ print '  \\a \rb' | IFS= read -rd $'\r' a; print -r "$a" | cat -vte
  \a $

[...]
>> 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.
>
[...]

But here, stdout is a regular file, not a pipe. Do you get the
same if you do rsync --progress -h --bwlimit=5 ./foo_in ./foo_out | cat -vet

Also, you could use ktrace/truss/strace or the equivalent on
your system to see if rsync is actually outputing those progress
lines.

-- 
Stephane



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