Description of problem: There is a problem with bash/sh scripts that use subshells. Two sample shell scripts below, both with nested subshells, the first works and the second doesn't. The difference is that the logical 'and' (&&) is on the end of line one in the first but on the beginning of line two in the second (which fails). There is no whitespace after the '\' delimiter. Version-Release number of selected component (if applicable): The above scripts are tested under RHEL 3 U3 Bash Version: 2.05b.0(1)-release (i386-redhat-linux-gnu) How reproducible: script which works: $ cat /tmp/test1 ((echo line1) && \ (echo line2)) $ sh /tmp/test1 line1 line2 script which fails: $ cat /tmp/test2 ((echo line1) \ && (echo line2)) $ sh /tmp/test2 /tmp/test2: line 2: syntax error near unexpected token `' /tmp/test2: line 2: `&& (echo line2))' Actual results: Expected results: The /tmp/test2 should work Additional info: I have tested with different version of bash, the script works only in bash version 1.14.7(1) on Linux. Below is the various errors thrown by different version of bash under Linux, 1. bash-1.14.7 - Works fine 2. bash-2.0 /tmp/test1: line 1: missing closing `)' for arithmetic expression /tmp/test1: line 1: syntax error near unexpected token `&' /tmp/test1: line 1: `((echo line1) && \' /tmp/test2: line 1: missing closing `)' for arithmetic expression /tmp/test2: line 1: syntax error near unexpected token `\' /tmp/test2: line 1: `((echo line1) \' 3. bash-2.01, bash-2.01.1, bash-2.02, bash-2.02.1, bash-2.03, bash-2.04, bash-2.05, bash-2.05a /tmp/test2: line 2: syntax error near unexpected token `&' /tmp/test2: line 2: `&& (echo line2))' 4. bash-2.05b (under RHEL 3 U3), bash-3.0 /tmp/test2: line 2: syntax error near unexpected token `' /tmp/test2: line 2: `&& (echo line2))' My observations in this problem are 1. Only bash version 1.14.7 is able to execute the script 2. Starting from bash-2.0 through bash-2.05a, the error message is same < syntax error near unexpected token `&' > 3. In bash-2.05b and bash-3.0 the error message does not include the '&' symbol < syntax error near unexpected token `' >
Reported upstream.
This will be fixed in a future release of GNU bash. Thanks for the report. http://lists.gnu.org/archive/html/bug-bash/2005-02/msg00032.html
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2006-0064.html
This issue is on Red Hat Engineering's list of planned work items for the upcoming Red Hat Enterprise Linux 4.4 release. Engineering resources have been assigned and barring unforeseen circumstances, Red Hat intends to include this item in the 4.4 release.