Given cmd='fun(){ echo $@;  }; fun $(fun $(fun hi))'shells tend to need to make 2 forks to make it happenstrace-f(){ strace -f $@ 2>&1; }; for sh in dash bash zsh ksh; do     printf $sh\t ; strace-f $sh -c $cmd  |grep -e clone -e fork -c;doneexcept ksh heroically makes it without forking once:dash    2bash    2zsh     2ksh     0How does it do that? Edit: Here's how it goes down with a pipe thrown in:cmd='fun(){ echo $@| echo $@;  }; fun $(fun $(fun hi))'Output:dash    11bash    10zsh     5ksh     3 
How does ksh93 avoid forks in command substitution
shell;ksh;command substitution;fork;optimization