Strange behaviour/bug in ash Variable substitution

Denys Vlasenko vda.linux at googlemail.com
Sat Jun 26 20:56:54 UTC 2010


On Saturday 26 June 2010 16:12, Ralf Friedl wrote:
> I have the following effect with this script:
> 
> $ cat /tmp/test.sh
> #!/bin/sh
> 
> IP=192.168.0.1
> echo "${IP//./\\.}"
> echo "${IP//./\\.}"' '
> echo "${IP//./\\.}"'['
> echo "${IP//./\\.}["
> echo "${IP//./\\\\.}["
> # end
> 
> $ ash /tmp/test.sh
> 192\.168\.0\.1
> 192\.168\.0\.1
> 192.168.0.1[
> 192.168.0.1[
> 192\.168\.0\.1[
> $ bash /tmp/test.sh
> 192\.168\.0\.1
> 192\.168\.0\.1
> 192\.168\.0\.1[
> 192\.168\.0\.1[
> 192\\.168\\.0\\.1[
> 
> The intent is to build a regular expression that has the dots quoted. It 
> works when nothing follows the substitution (1. echo). It works when 
> followed by a quoted space, or every other character I tried (2. echo). 
> The quote doesn't appear when it is followed by an opening bracket, 
> either in single quotes or in double quotes (3. echo and 4. echo). It 
> seems that in this case extra backslashes are needed (5. echo). The 
> substitution is performed, but the following bracket somehow causes an 
> extra unquoting of the argument.
> The results with bash are different.
> BusyBox is v1.16.1.

Please try attached patch.
-- 
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1.patch
Type: text/x-diff
Size: 3967 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20100626/7cba2a1d/attachment.bin>


More information about the busybox mailing list