Bug 42282 - read command does not accept input from pipe.
Summary: read command does not accept input from pipe.
Status: CLOSED DUPLICATE of bug 19747
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: bash
Version: 7.1
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Bernhard Rosenkraenzer
QA Contact: David Lawrence
Depends On:
TreeView+ depends on / blocked
Reported: 2001-05-25 15:02 UTC by Lisa Rojas
Modified: 2007-04-18 16:33 UTC (History)
0 users

Clone Of:
Last Closed: 2001-05-25 15:02:58 UTC

Attachments (Terms of Use)

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:

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

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

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 ***

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