Bug 146638

Summary: sub-shells fail when logical operators start on new line
Product: Red Hat Enterprise Linux 3 Reporter: Saravanan <nobody+svenkat>
Component: bashAssignee: Tim Waugh <twaugh>
Status: CLOSED ERRATA QA Contact: Ben Levenson <benl>
Severity: low Docs Contact:
Priority: medium    
Version: 3.0CC: poelstra, tao
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2006-0064 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-03-15 15:38:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 168424, 178788    
Attachments:
Description Flags
patch from Chet none

Description Saravanan 2005-01-31 10:58:28 UTC
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 `' >

Comment 1 Tim Waugh 2005-01-31 12:16:24 UTC
Reported upstream.

Comment 2 Tim Waugh 2005-02-08 15:21:58 UTC
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

Comment 17 Red Hat Bugzilla 2006-03-15 15:38:57 UTC
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


Comment 18 Bob Johnson 2006-04-11 16:07:36 UTC
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.