My bash
man page for version 4.4.19 says:
Pipelines
A pipeline is a sequence of one or more commands separated by one of the control operators
|
or|&
. The format for a pipeline is:
[time [-p]] [ ! ] command [ [|||&] command2 ... ]
Sure. That makes sense. Then, later in that section:
Each command in a pipeline is executed as a separate process (i.e., in a subshell).
Also reasonable, and easily proved:
$ pwd
/Users/ravron
$ ls | grep src # yes, src _does_ exist
src
$ cd src | true # cd in subshell has no effect on parent session
$ pwd
/Users/ravron
However, I noticed that the definition of a pipeline, above, is worded such that even a simple command is a pipeline. After all, in the syntax, everything except command
is optional:
[time [-p]] [ ! ] command [ [|||&] command2 ... ]
Now, of course, running even single commands — in man bash
terminology, "simple commands" — in subshells would be really quite useless. cd
wouldn't work, variable setting wouldn't work, etc. However, the reality — that simple commands, despite matching the syntax for a (rather degenerate) pipeline, are not executed in subshells — appears to be at odds with the man page. In list form, here's my understanding:
- The syntax for pipelines means that simple commands are also pipelines.
- The man page says that the commands in a pipeline are run in subshells.
- Simple commands are not run in subshells.
What am I missing, or is this an admittedly inconsequential bug in man bash
?