Bash functions are better than I thought
Getting anything out of a subshell that isn&#x27;t from STDOUT is impossible. So you can&#x27;t define an array in a subshell and then use it outside the subshell, and you can&#x27;t return an array (or anything that isn&#x27;t a string) from a subshell. If you only use subshells and want to use any kind of data structure that isn&#x27;t a string passed from STDOUT, you have to do it globally. And subshells are slow. So nobody uses subshells.<p>If you use Bash for programming, you have to stop thinking in terms of the holier-than-thou software engineer, whose ego believes that a superior, &quot;clean&quot; design makes a superior program. You should embrace globals. You should switch between using or not using the enforcement of set variables or program exit status. You should stop using Bashisms and subtle, obscure language features unless you absolutely have to.<p>Bash is not a &quot;real&quot; programming language, so do not treat it as one. Do not look for hidden features, or try to do things in cute ways that nobody else uses. There is no superior method or hidden knowledge. Just write extremely simple code and understand the quirks of the shell.