There are 2 main ways that I know of so far:
-
Explicitly: wrapping parentheses around a list of commands
-
Implicitly: every command in a pipeline
Are there more ways, either explicitly or implicitly, in which one creates subshells in bash?
bashsubshell
There are 2 main ways that I know of so far:
Explicitly: wrapping parentheses around a list of commands
Implicitly: every command in a pipeline
Are there more ways, either explicitly or implicitly, in which one creates subshells in bash?
Best Answer
From
man bash
:&
, the shell executes the command in the background in a subshell. The shell does not wait for the command to finish, and the return status is 0.coproc
reserved word.A coprocess is executed asynchronously in a subshell, as if the command had been terminated with the & control operator
complete
command: when called with the-C command
option,command
is executed in a subshell environment, and its output is used as the possible completions.