bump: ash variable substitution, quote slash

Bastian Bittorf bittorf at bluebottle.com
Wed Sep 23 08:47:10 UTC 2015


* Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com> [23.09.2015 10:44]:
> > so basically this does not work (no matter how I escape)
> > var='a/c'; echo ${var////b}
>                        ^^^^
> That looks like a bashism (not portable).  Is it this:
> 
> 	${parameter/pattern/string}
> 
> you're trying to use?  In that case, this:
> 
> 	v=a/c && echo ${v/\//b}
> 
> should work for you.

no, as I wrote 'no matter how I escape' - it does not work.
(busybox git HEAD)

> > (should output 'abc')
> 
> But you can do that in a portable way too:
> 
> 	v=a/c && echo ${v%%/*}b${v#*/}
> 
> (exchange the 1st '/' char in variable v for char 'b')

8-) this was only an example - the real usecase is,
that i have var='/path/to/my/file' and want to change '/' -> '\/'
for using in a sedline like:

sed -i "/$pattern/d" $file

thanks for your comment - bye, bastian


More information about the busybox mailing list