[buug] loops and pipe sinks are subshells, aaaargh
Ian Zimmerman
itz at buug.org
Wed Aug 3 15:26:45 PDT 2011
Ian> After all these years with Unix I still don't know how to deal with
Ian> this annoying misfeature of the shell, without going into
Ian> ridiculous contortions:
Ian> [30]matica:~$ foo=1 ; for a ; do foo=bar ; done [31]matica:~$ echo
Ian> $foo 1
This example is bogus - the loop doesn't get executed. This works:
[40]matica:~$ foo=1 ; for a in baz ; do foo=bar ; done
[41]matica:~$ echo $foo
bar
So, it's the pipe that is the sole culprit, not the loop.
Still looking for answers in the pipe case ...
--
Ian Zimmerman
gpg public key: 1024D/C6FF61AD
fingerprint: 66DC D68F 5C1B 4D71 2EE5 BD03 8A00 786C C6FF 61AD
Rule 420: All persons more than eight miles high to leave the court.
More information about the buug
mailing list