Failing shell code under busybox 1.36.1 that worked with 1.31.1

David Laight David.Laight at ACULAB.COM
Thu Feb 15 12:23:21 UTC 2024


From: David Leonard
> Sent: 15 February 2024 08:46
> To: Harvey <harv at gmx.de>
> Cc: busybox at busybox.net
> Subject: Re: Failing shell code under busybox 1.36.1 that worked with 1.31.1
> 
> 
> >         _result="$_result '${_p//'/'\"'\"'}'"
> 
> Busybox ash has a CONFIG_ASH_BASH_COMPAT config to get this ${var//...}
> replacement behaviour.  And, in bash, the ' in the pattern section is treated
> as a quote start. To give the ' a literal meaning, use \'
> eg ${_p//\'/..repl..}
...

It is probably safer to the quotes into variables.
Then the syntax analysis won't get messed up.

So something like:
sq="'"
qsq='"'"'"'"'

then
	"${_p/$sg/$qsq}"

is probably ok and maybe more readable.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


More information about the busybox mailing list