Bug 8466

Summary: ash parses test parameters
Product: Busybox Reporter: alt.f2-5ok1zywx
Component: Standard ComplianceAssignee: unassigned
Status: RESOLVED FIXED    
Severity: minor CC: busybox-cvs
Priority: P5    
Version: 1.22.x   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:

Description alt.f2-5ok1zywx 2015-11-15 20:21:32 UTC
[ "(" = foo ] && echo foo

sh: closing paren expected
Comment 1 bugdal 2015-11-15 20:34:16 UTC
Here is the specification:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html

The text explaining why bb ash's behavior is wrong:

"3 arguments:

- If $2 is a binary primary, perform the binary test of $1 and $3.

- If $1 is '!', negate the two-argument test of $2 and $3.

- [OB XSI] [Option Start] If $1 is '(' and $3 is ')', perform the unary test of $2. [Option End]  On systems that do not support the XSI option, the results are unspecified if $1 is '(' and $3 is ')'.

- Otherwise, produce unspecified results."

In the case of this bug, $2 is the binary primary =. Thus the first rule takes precedence. BB ash is wrongly giving the third rule for the obsolescent parens precedence.
Comment 2 Denys Vlasenko 2016-01-17 03:02:43 UTC
Can't reproduce. I think I remember how this was fixed sometime ago. Try most recent released version.