3

As far as I know

echo $$

shows the PID of the current BASH I am in.

I do not know if the expasnsion $(...command...) runs the command in a subshell or the current shell, however

echo $(echo $$)

shows the same PID But, as for (...command...) I was very sure, that the command is run inside a subshell and therefore in a shell with another PID than the current shell, but

(echo $$)

shows also the same PID

So, in all three cases the same PID,namely 1771, was displayed. I am confused, based on what I learned so far, I would not have expected it. Why?

sharkant
  • 3,710

0 Answers0