Subject: Re: bug in sh?
To: None <email@example.com>
From: Chet Ramey <chet@odin.INS.CWRU.Edu>
Date: 05/25/1995 11:28:29
> Could someone tell me if this is proper behavior for sh, a known bug,
> or a newly discovered critter? the shell was suped just a few days ago,
> rebuilt and installed. Anyway, here is what happened:
This is not a bug in sh.
> grep "^$1" ./data | read key data1 data2 data3
This `read' command is performed in a subshell, since it is part of a
pipeline. A subshell cannot affect the values of variables in its
> grep "^$1" ./data | while read key data1 data2 data3
> echo $key - $data1 - $data2 - $data3
The `read' and `echo' are part of the same subshell in this code
fragment, so the variables have values.
``The lyf so short, the craft so long to lerne.'' - Chaucer
Chet Ramey, Case Western Reserve University Internet: chet@po.CWRU.Edu