Bug 2281

Summary: sh: behavior of backslash star inside parameter expansion
Product: Busybox Reporter: Stanislav Brabec <sbrabec>
Component: Standard ComplianceAssignee: unassigned
Status: RESOLVED DUPLICATE    
Severity: minor CC: busybox-cvs
Priority: P5    
Version: 1.13.x   
Target Milestone: ---   
Hardware: All   
OS: All   
Host: Target:
Build:

Description Stanislav Brabec 2010-07-23 11:51:41 UTC
There was a bug in expansion of star inside parameter in expressions like ${FOO//\\*/-star-}. In bash 2 and lower two backslashes were eaten for escaping of star. Since bash 3 the bug is fixed. The fix introduced a small change of the behavior (one backslash escapes second backslash). Also zsh already migrated to the fixed behavior.

Busybox exactly follows (at least in version 1.13) the bash 2 behavior considered as broken. It would be nice to migrate it to the fixed behavior.

Example:

FOO="a*b\\*c" ; echo ${FOO//\\*/-backslashstar-}

Bash 2, busybox:
a-backslashstar-b-\backslashstar-c

Bash 3, Bash 4, zsh:
a*b-backslashstar-
Comment 1 Denys Vlasenko 2010-08-11 21:47:52 UTC
Fixed in git. While at it, found and quashed two more bugs.
However, quoted version:

FOO="a*b\\*c"; echo "${FOO//\\*/-backslashstar-}"

is still broken, and is _hard_ to fix.

There is now a testcase for it:
Go to busybox/shell/ash_test in buld tree and run "run-all".
Examine ash-vars-var_bash4.tests.fail to see quoted expansion error.
Comment 2 Denys Vlasenko 2010-10-30 02:54:48 UTC

*** This bug has been marked as a duplicate of bug 2695 ***