Pipeline to the process when the process does not exist?

Let's say I start with the following statement: echo -s line is broadcast:

 $ echo "foo" 1>/dev/null 

Then I send the following pipeline:

 $ echo "foo" | cat -e - 1>/dev/null 

Then I will leave the process:

 $ echo "foo" | 1>/dev/null 

Why does this not return an error message? Perhaps the reason may be the bash and pipeline documentation, which does not seem to give a direct mention. Is there an EOF dispatched before the first read from echo (or whatever process works before the thread)?

+8
unix bash pipe
source share
1 answer

The command line does not require a command line. For a team without a command-name:

  • variable assignments apply to the current runtime. Two variables for argument values ​​will be listed below:

     arg1=$1 arg3=$3 
  • redirects occur in a subshell, but the subshell does nothing but initialize the redirection. The following will truncate or create the specified file (if you have the appropriate permissions):

     >/file/to/empty 

However, a team must have at least one word. A completely empty command is a syntax error (therefore, sometimes it is necessary to use : .

The answer is summarized from Posix XCU & sect; 2.9.1

+8
source share

All Articles