sh -c '/bin/cat /proc/self/comm - </proc/self/comm'
The pattern will be similar if I use
dash instead of
sh. But with
zsh the result is
/proc/self/stat instead of
/proc/self/comm I can confirm the two
cat-s are in fact the same single process. Apparently shells differ under the hood, it's OK. Now let's take
sh -c '/bin/cat /proc/self/environ - </proc/self/environ'
Having observed the above, with
dash I expect to see the environment of the
cat first, the environment of the shell later. It seems to work (both environments are most likely identical anyway so it's hard to tell if everything works as expected, but my point is: neither
environ is empty).
zsh I expect to see the environment of the
cat twice, but it's only printed once. Splitting into two separate cases:
bash -c '/bin/cat - </proc/self/environ'prints nothing, as if
bash -c '/bin/cat /proc/self/environ'prints something as expected.
What is going on? This is not the case with
stat. Why is
$ uname -a Linux barbaz 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1 (2018-04-29) x86_64 GNU/Linux