Quote:
Originally Posted by
wisecracker
In my defence I was refering to the builtin commands not transient ones from the external storage source, (HDD).
I have understood that. The problem is the following: when the shell reads and executes shell code there are three possible ways to do that:
1) builtins: the shell executes them itself. This means there is a provision inside the shells binary code which gets executed. This is the case with builtins, reserved words (which is not the same, but for our purposes equal), variable expansion and similar syntactical devices. Into this group falls "if", "do", "while", "[[" (test), "((...))", etc..
2) externals: the shell simply loads and executes them. A separate process (child process) is created for every such binary.
3) process substitution/subshells: This is similar to externals but first a subshell is created as a child process and then the command is executed within this subshell.
$( command1 [ | command2 | ... ] ) means: create a child process and start a shell there, then execute the shell code
command1 [ | command2 | ... ] there, applying the same rules as if it where a one-line script. If
command1 is a builtin it is processed like any builtin, but not from the original shell, though! It is processed by the child process. All this happens during commandline evaluation (of the main shell). Finally the output of the child shell is collected, the "$( ... )" is replaced by this collected output and the resulting line is executed.
You see, the process substitution involves the same process creation (
exec(), ...) as the external do. Even more so when the commands in the subshell are externals themselves.
I hope this helps.
bakunin