I tried the following command on bash
echo this || echo that && echo other
This gives the output
this
other
I didn't understand that!
My dry run goes this way :
echo this || echo that && echo other
implies true || true && true
- Since,
&&
has more precedence
than ||
, the second expression evaluates first
- Since,
both are true
, the ||
is evaluated which also gives true.
- Hence, I conclude the output to be:
that
other
this
Being from a Java background where &&
has more precedence than ||
, I am not able to relate this to bash.
Any inputs would be very helpful!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…