sh shell - pattern substitution bug?

Richard Moore rich at richud.com
Fri Jan 9 19:34:22 UTC 2015


Hi Steven,

There are similar tests in
busybox-1.23.0/shell/ash_test/ash-vars/var_bash3.tests
which leads me to think it should work, but they don't cover quoted 
replacements.

The inconsistent behaviour (below) leads me to think there some sort of 
backslash addition bug rather than a lack of function?

~ # i="a#b#c"
~ # echo ${i//#/':'}
a\:b\:c
~ # echo ${i//#/';'}
a;b;c
~ # echo ${i//#/'*'}
a\*b\*c
~ # echo ${i//#/'^'}
a^b^c

Thank you for your time,

Regards

Rich


On 09/01/15 13:29, Steven Honeyman wrote:
> On 8 January 2015 at 22:42, Richard Moore <rich at richud.com> wrote:
>> Hi,
>>
>> I think this is a pattern substitution bug with bb's bourne shell?
>> (afraid I cant find anything with a real shell (non-dash) to double check
>> on, so apologies if it is me.)
>>
>>
>> busybox 1.23.0 (sh shell)
>> -------------------------------------
>> ~ # i=stuff%%this%%that
>> ~ # j=${i//%%/$'\x0A'}
> Pattern substitution is just a bashism as far as I know, so no reason
> to expect this to work in any other shell.



More information about the busybox mailing list