On Thu, Feb 15, 2024 at 9:52 AM David Leonard <d+busy...@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). _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox