There are no booleans in the shell scripts.
Best simulation for them are integer values.
[[ -v variable_name ]] will return
1 if the
variable_name was not defined or
0 if it was.
Therefore, you can get your desired behavior with this:
// If one of the variables is defined, return value of this command is 0.
[[ -v r2g_keep_temp ]] || [[ -v r2g_multi_temp ]]
// Save the return value of the last command (0 or 1).
Of courese, you can interpret the numbers however you like, I just wanted to demonstrate one example.
By the way,
local r2g_multi=$("$r2g_multi_temp" || "$r2g_keep_temp");
is not the thing that you wish.
- First the variables
r2g_keep_temp will be replaced by their values.
- Now the subshell will try to execute the value of the
- If by some miracle that value is a valid bash command there are 2 cases:
- That command is executed succesfully and its
stdout is saved in the
- That command failed and subshell invoked the value of the
Similar story again, if it is a valid command it will be executed and its
stdout will be appended on the possible
stdout of the command executed from the value of
r2g_keep_temp and everything will be stored in
All in all, run away from this :D