[buug] loops and pipe sinks are subshells, aaaargh

Tony Godshall togo at of.net
Thu Aug 4 12:55:31 PDT 2011


>  [34]matica:~$ echo bar > baz
>  [35]matica:~$ foo=1
>  [36]matica:~$ cat baz | while read line ; do foo=$line ; done
>  [37]matica:~$ echo $foo
> 1
>
> Help?  I understand _why_ this is happening (see Subject), I want a
> solution.  And a pony too!

Well, a pipe does need two processes so you can have concurrent
execution, otherwise you'd have a MSDOS-style pipe

T



More information about the buug mailing list