"Andrew Robb" <arobb@mva.co.uk> wrote:
> The shell function is not running in a separate process,
It is. You can observe this with a system call trace.
> $$ gives the same value in the shell function as the calling
> process.
$$ also gives the same value inside an explicit subshell like
"(command)"; would you claim that no extra process is created then?
$$ doesn't mean what you think it means in these situations. It is
initialized with getpid() when the shell first starts, and is not
reset for subprocesses.
You might make a feature request, saying that bash *shouldn't* fork a
subprocess when the pipeline element is a shell function. But that is
indeed what it does currently.
paul