Here is a much concise example if someone cares :
cd / && cd /tmp/ | pwd ; pwd / /
Or :
cd / && cd /tmp/ | cd /var/ ; pwd /
Or :
i=0; i=1 | echo $i ; echo $i 0 0
idx=0; { ((++idx)); echo $idx >&2; } | echo $idx ; echo $idx 0 1 0
Yes this page says it all
http://linux.die.net/man/1/bash# Each command in a pipeline is executed as a separate process (i.e., in a subshell).
http://stackoverflow.com/questions/5760640/left-side-of-pipe-is-the-subshell/22054804#22054804
f_() { t=0 { t=1; echo "inside subshell=$t" ; return $t ;} | cat echo PIPESTATUS=${PIPESTATUS[0]} # 0 echo "outside subshell = $t" # 0 } f_