bump: ash variable substitution, quote slash

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Wed Sep 23 07:52:19 UTC 2015


On Wed, 23 Sep 2015, Bastian Bittorf wrote:
>
> trying to replace a slash in a variable using
> substitution I stumbled over this old thread:
> http://lists.busybox.net/pipermail/busybox/2010-September/073290.html
>
> 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.

> (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')


Cheers,

-- 
Cristian


More information about the busybox mailing list