Failing shell code under busybox 1.36.1 that worked with 1.31.1
Denys Vlasenko
vda.linux at googlemail.com
Mon Feb 26 15:39:40 UTC 2024
On Thu, Feb 15, 2024 at 9:52 AM David Leonard
<d+busybox at adaptive-enterprises.com> wrote:
> > _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..}
>
> In current busybox ash you will run into a bug where quotes aren't
> handled in the pattern, and even loses the rest of the word, as you
> observed. That is, given this script:
>
> var="don't g/o"
> echo "${var/'/'o}!"
> echo "${var/\'/\'o}!"
>
> bash outputs:
>
> don't g! (pattern="/o" repl="")
> don'ot g/o! (pattern="'", repl="'o")
>
> and busybox ash outputs:
>
> don't g/o (pattern=?, repl=?, NOTE: lost !)
> don'ot g/o! (pattern="'", repl="'o")
>
> Here's a patch to make ash a little bit closer to bash.
Thank you, applied (with some changes, but the same idea).
More information about the busybox
mailing list