ash variable substitution, quote slash

Ralf Friedl Ralf.Friedl at online.de
Fri Sep 3 12:58:16 UTC 2010


Hi

I'm using BusyBox v1.17.2 ash. It seems that it is impossible to replace 
a forward slash in a variable expansion, even if the slash is quoted:

$ busybox ash
$ VAR=ab/cd; echo ${VAR//[^\/]/}
ab/cd
$ VAR='ab/cd'; echo ${VAR//\//}
ab/cd
$ VAR='a[^b/cd'; echo ${VAR//[^/]/}
a[^b/cd

$ bash
$ VAR=ab/cd; echo ${VAR//[^\/]/}
/
$ AR='ab/cd'; echo ${VAR//\//}
abcd
$ VAR='a[^b/cd'; echo ${VAR//[^/]/}
a]/b/cd

The real pattern I want to use is a little more complicated, but the 
difference comes from the slash that works when quoted in bash and 
doesn't work in ash.
The slash outside of the set also doesn't work.
The difference in the third pattern is not important for me at the 
moment, but I tried to understand what happens with this pattern. In 
bash it seems the pattern is split at the slash and '[^' is replaced 
with ']'. Busybox ash seems to behave differently.

Ralf Friedl


More information about the busybox mailing list