Subject: Re: [RFC PATCHv3 1/4] am: avoid re-directing stdin twice

From: Torsten Bögershausen <[email-masked]>
Date: Sat, 06 Sep 2014 14:46:32 +0200

On 2014-09-06 09.34, Junio C Hamano wrote:
> Stephen Boyd <[email-masked]> writes:
> 
>>>> I see Stephen who wrote the original "Thunderbird save-as" is
>>>> already on the Cc list.  How about doing it this way instead?
>>
>> It was so long ago I can't even remember writing that patch. But I
>> googled the thread from 4.5 years ago and I see that you suggested we
>> use tr because \r is not portable[1].
> 
> Hmph.  That's unfortunate that this may be one of those things that
> even though it is in POSIX the real world prevents us from using it.
> 
> I wonder if things changed over the past four years, though.  Can
> folks on OSX or BSD do a quick check?
>
I may have missed the discussion, does this help?
"\r" can be used with tr, but not with sed:

tb@macosx:/tmp> cat ./xx.sh 
#!/bin/sh
which tr
printf "AB\rCD\n" | tr 'A\r\n\BCD' 'aRNbcd' | xxd
printf "E\rE" | tr -d '\r' | xxd
which sed
printf "AB\rCD\n" | sed -e  's/\r/R/g' | xxd
printf "E\rE" | sed -e 's/\r//g' | xxd

tb@macosx:/tmp> ./xx.sh 
/usr/bin/tr
0000000: 6162 5263 644e                           abRcdN
0000000: 4545                                     EE
/usr/bin/sed
0000000: 4142 0d43 440a                           AB.CD.
0000000: 450d 450a                                E.E.
tb@macosx:/tmp>