I'm a beginner at Linux shell, but I know that this command creates a subshell:
Subshells are typically created using subshell operators or commands such as parentheses (), backticks `, or the $() syntax.
: ${FOO:=$([ "$BAR" = "baz" ] && echo "true" || echo "false" )} This could be a problem e.g. in a loop (this is not the case here) but I like to learn how to avoid it. Generally speaking, in the above assignment, can a subshell be avoided using the following?
if [ -z "$FOO" ]; then if [ "$BAR" = "baz" ]; then FOO=true else FOO=false fi fi
trueandfalsewith$BASH_SUBSHELLand check the output.