Problems with '\r' handling by 'sed' applet (BusyBox versions up to 1.18.4)

Tomasz Czapiewski xeros at irc.pl
Tue May 3 20:34:37 UTC 2011


On Tue, 3 May 2011, Denys Vlasenko wrote:

> On Monday 02 May 2011 08:00, Tomasz Czapiewski wrote:
>> Busybox 'sed' handles '\r' in replacements differently than real 'sed'.
>>
>> Examples from BusyBox sed:
>> # echo 'something' | busybox sed 's/something/something\r/g'
>> somethingr
>> # echo 'rambo' | busybox sed 's/\r//g'
>> ambo
>> # echo -e 'rambo\r and \rrambo' | busybox sed 's/\r//g'
>> ambo
>>
>> While outputs of the same using real 'sed':
>> # echo 'something' | sed 's/something/something\r/g'
>> something
>> # echo 'rambo' | sed 's/\r//g'
>> rambo
>> # echo -e 'rambo\r and \rrambo' | sed 's/\r//g'
>> rambo and rambo
>>
>> This make some problems with my scripts portability.
>> None of BusyBox 'sed' applet parameters, like '-r' help to solve it.
>
> Try this patch:
>
> http://git.busybox.net/busybox/commit/?id=6a0abcc02f0773f32f2d31b3532eec1b11e1f67d
>

Thank you very much!

-- 
xeros


More information about the busybox mailing list