Bug 42282

Summary: read command does not accept input from pipe.
Product: [Retired] Red Hat Linux Reporter: Lisa Rojas <ladycomix>
Component: bashAssignee: Bernhard Rosenkraenzer <bero>
Status: CLOSED DUPLICATE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-05-25 15:02:58 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:

Description Lisa Rojas 2001-05-25 15:02:54 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.7 [en]C-CCK-MCD {LabCorp}  (Win95; U)

Description of problem:
Simplified version
*********************************
echo 1 | read a
echo $a

*******************
The variable a does not come out as the expected 1.  Instead, the variable is unset. 
Note this problem also appears in pdksh.   

How reproducible:
Always

Steps to Reproduce:
1. echo 1 |read a
2.echo a
3.
	

Actual Results:  variable is not set.

Expected Results:  Variable should be set to 1 in the example.  

Additional info:

Comment 1 Bernhard Rosenkraenzer 2001-05-28 07:02:00 UTC
This is what the Single UNIX spec says:

"Some systems have implemented the last stage of a pipeline in the current
environment so that commands such as: 

    command | read foo

set variable foo in the current environment. This extension is allowed, but not
required; therefore, a shell programmer should consider a pipeline to be in a
subshell environment, but not depend on it."

And 'man bash' (line 277) says:

"Each  command in a pipeline is executed as a separate process (i.e., in a
subshell)."

So it isn't really a bug in bash, as far as I can see.


*** This bug has been marked as a duplicate of 19747 ***