Bug 696742

Summary: Terminating whitespace significant in "here" document marker
Product: Red Hat Enterprise Linux 5 Reporter: David Tonhofer <bughunt>
Component: bashAssignee: Roman Rakus <rrakus>
Status: CLOSED NOTABUG QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 5.8CC: prc, tsmetana
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-04-15 13:08:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description David Tonhofer 2011-04-14 18:40:02 UTC
Description of problem:

Whitespace is significant in a "here" document marker.

For example:

cat >> test.txt << HERE
   foo barr baz
HERE

would work perfectly if HERE has no whitespace at the end, but

cat >> test.txt << HERE
   foo barr baz
HERE 

with the last string being actually "HERE " would fail hard for nonobvious reasons.

--> Bash should trim the line before comparing it to the here "here" tag.

Version-Release number of selected component (if applicable):

bash-3.2-24.el5

How reproducible:

Always

Comment 1 Roman Rakus 2011-04-15 13:08:22 UTC
(In reply to comment #0)
> Description of problem:
> 
> Whitespace is significant in a "here" document marker.
> 
> For example:
> 
> cat >> test.txt << HERE
>    foo barr baz
> HERE
> 
> would work perfectly if HERE has no whitespace at the end, but
> 
> cat >> test.txt << HERE
>    foo barr baz
> HERE 
> 
> with the last string being actually "HERE " would fail hard for nonobvious
> reasons.
> 
> --> Bash should trim the line before comparing it to the here "here" tag.
Should not! See posix: http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_07_04
> 
> Version-Release number of selected component (if applicable):
> 
> bash-3.2-24.el5
> 
> How reproducible:
> 
> Always