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

Re: freebsd problems with carriage return

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.

>      done
> as rsync uses a carriage return to update the progress of the file 
> transfer, the "read" builtin uses '\r' as a delimiter, and prints the 
> output as expected, one line at a time.
> on freebsd it doesn't work at all.

In which way does it not work?

> i suspect the bug may be in bsd's 
> libraries, because a similar thing happens on linux and fails to happen on 
> freebsd with:
>      rsync --progress /from /to | tr '\r' '\n'
> of course linux is using gnu-tr and freebsd is using bsd-tr.
> can anyone help identify the source of the problem, and/or a workaround?


rsync --progress /from /to | sed -n l

(or od -c)

to see what rsync actually outputs.

Also, in case rsync outputs it on stderr, try:

rsync --progress /from /to 2>&1 | sed -n l


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