On Mon, Aug 02, 2021 at 02:43:36PM +0000, hancooper wrote:
> Do (-d "$dir") and (! $list_raw) also fork a subshell?
Outside of the [[ ]] command, yes.
Inside of the [[ ]] command, no.
> Is it fine to fork subshells when using conditions as I do? I do not know
> much about
> whether forking of subshells in bash is good, bad, or whatever.
It's bad. It's a massive performance hit for no reason.
On Mon, Aug 02, 2021 at 02:46:46PM +0000, hancooper wrote:
> Then doing
>
> if [[ -d "$dir" && ! $list_raw ]]; then
>
> or
>
> if [[ -d "$dir" ]] && [[ ! $list_raw ]]; then
>
>
> is simply dependent on preference, rather than functionality?
Yes. Also, the one with parentheses INSIDE the [[ ]] command is fine
as well.
Just don't put parentheses OUTSIDE.