Bug 146638 - sub-shells fail when logical operators start on new line
Summary: sub-shells fail when logical operators start on new line
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: bash
Version: 3.0
Hardware: i386
OS: Linux
medium
low
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks: 168424 178788
TreeView+ depends on / blocked
 
Reported: 2005-01-31 10:58 UTC by Saravanan
Modified: 2007-11-30 22:07 UTC (History)
2 users (show)

Fixed In Version: RHBA-2006-0064
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-03-15 15:38:57 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
patch from Chet (1.22 KB, patch)
2005-03-22 11:30 UTC, Tim Waugh
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2006:0064 0 qe-ready SHIPPED_LIVE bash bug fix update 2006-03-14 05:00:00 UTC

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.


Note You need to log in before you can comment on or make changes to this bug.