On 1/31/16 7:26 PM, Michael Diamond wrote: > Bash Version: 4.3 > Patch Level: 39 > Release Status: release > > Description: > I'm told $((( $exit_code == 0 )) && echo GREEN || echo RED) should fail > to parse, because $(( should be the first token, not $(.
The way I read Posix, the bash behavior is allowed: "The syntax of the shell command language has an ambiguity for expansions beginning with "$((", which can introduce an arithmetic expansion or a command substitution that starts with a subshell. Arithmetic expansion has precedence; that is, the shell shall first determine whether it can parse the expansion as an arithmetic expansion and shall only parse the expansion as a command substitution if it determines that it cannot parse the expansion as an arithmetic expansion." One of the criteria bash uses to determine whether it's a valid arithmetic expression is whether or not the parentheses are balanced. It's basically up to the application to remove the ambiguity. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/