Im trying to nest if else bash statements using [[..]] but I seem to be running into issues:
my line:
[[ $WRD == "tmp" ]] && tmpFlag=1 || [[ $someOtherVar == "test" ]] && tempFlag=2 || tempFlag=3
Basically, if WRD is tmp, then flag is 1, else if $someOtherVar is test, then the flag is 2 and if all else fails, then set the flag to 3.
But this level of nesting doesnt work.
- If I provide WRD as tmp, flag is set to 2. [WRONG]
- If I do not provide a WRD and
$someOtherVarisn'ttest, then it is set to 3. [CORRECT]. - If I do not provide a WRD and
$someOtherVaristest, then it is set to 3. [WRONG]
[[...]]functionalityWRDis set totmpthen the statement[[ $WRD == "tmp" ]] && tmpFlag=1 || [[ $someOtherVar == "test" ]]succeeds (as a "whole"), sotempflag=2is executed.