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