ksh if with several conditions

10,192

Whatever $tmpEngine value, this test is always true, I mean, $tmpEngine cannot be a, b and s at the same time so at least two of the comparisons are always true.

You probably want:

if [[ "$tmpEngine" != "a" && "$tmpEngine" != "b" && "$tmpEngine" != "s" ]]; then
   ...
fi
Share:
10,192

Related videos on Youtube

user1058398
Author by

user1058398

Updated on September 18, 2022

Comments

  • user1058398
    user1058398 almost 2 years

    I'd like to know what's the syntax for this kind of if in ksh :

    if [[ $tmpEngine != "a" || $tmpEngine != "b" || $tmpEngine != "s" ]]; then
       ...
    fi
    

    Actually, my code doesn't work, what's the problem here ? The problem is not about the meaning of my if, but rather how to write it correctly from a syntax point of view.

  • user1058398
    user1058398 over 10 years
    You right, small mistake from my side but anyway, my code doesn't work because of a syntax problem.
  • jlliagre
    jlliagre over 10 years
    Do you mean my answer doesn't address the problem described ?