1

From Bash Reference Manual

A pipeline is a sequence of simple commands separated by one of the control operators | or |&.

From POSIX 2013

A pipeline is a sequence of one or more commands separated by the control operator |.

I know that Bash has many extensions to POSIX shells, e.g. |&.

But are the component commands of a pipeline

  • simple commands or
  • just any commands (simple, pipeline again, list, compound, and function)?

In Bash, the following works

$ for f in $(ls *); do echo $f; done | cat

but the first component command of the pipeline isn't simple but compound.

asked Mar 22, 2016 at 19:34
2
  • And just to confuse you more ,echo is a built-in command of bash, but there is also /bin/echo that does almost exactly the same thing Commented Mar 22, 2016 at 21:58
  • you probably want backticks acound the ls *, I tried to edit, but it wouldn't let me make such a minor edit. Needed more characters. Put 5 spaces in front of that line, which marks up as 'code', then you can add the backticks Commented Mar 22, 2016 at 22:11

2 Answers 2

7

The manual for Bash 4.4.5 does not contain the word "simple" from the description of what a pipeline is made up of. The "simple command" you're referring to was probably either a typo or an oversight, or possibly a leftover from a long time ago.

It was fixed by the bash maintainer in April 2014, and it currently reads:

A pipeline is a sequence of one or more commands separated by one of the control operators | or |&.

A pipeline can clearly be made up from commands that or not simple commands (for example subshells and for loops, which are compound commands).

answered Dec 29, 2016 at 16:58
1
1

Bash manual (man bash) has never included the word simple in the description of a pipeline. Get any of the bash-${version}.tar.gz files from this site, decompress and take a look at the file bash-${version}/doc/bash.1 which is the manual of bash for each version.

What has included the word simple is the bashref file. From the same downloaded and expanded file as above, read bash-${version}/doc/bashref.pdf, which has included the word simple at point 3.2.2 Pipelines up to version 4.3 of the said bashref manual.

3.2.2 Pipelines A pipeline is a sequence of simple commands separated by ... ‘|’ or ‘|&’.

That the bashref included such word has never meant that complex commands (as opposed to "simple") were in any way excluded from being used as part of a pipeline (including {...} if...then... while...do... and others).

Such wording is a simple typo and should not be used to extract any conclusion.

answered Jan 1, 2017 at 5:35

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.