Bug 146638 - sub-shells fail when logical operators start on new line
sub-shells fail when logical operators start on new line
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: bash (Show other bugs)
3.0
i386 Linux
medium Severity low
: ---
: ---
Assigned To: Tim Waugh
Ben Levenson
:
Depends On:
Blocks: 168424 178788
  Show dependency treegraph
 
Reported: 2005-01-31 05:58 EST by Saravanan
Modified: 2007-11-30 17:07 EST (History)
2 users (show)

See Also:
Fixed In Version: RHBA-2006-0064
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-03-15 10:38:57 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Saravanan 2005-01-31 05:58:28 EST
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 07:16:24 EST
Reported upstream.
Comment 2 Tim Waugh 2005-02-08 10:21:58 EST
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 10:38:57 EST
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 12:07:36 EDT
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.