&&
if (( $1 != 0 || $1 != 3 )) then echo "$1 is not 0 or 3" fi
if (( $1 != 0 && $1 != 3 )) then echo "$1 is not 0 or 3" fi
This is not a bash issue, but a simple, common logical mistake applicable to all languages.
(( $1 != 0 || $1 != 3 )) is always true:
(( $1 != 0 || $1 != 3 ))
$1 = 0
$1 != 3
$1 = 3
$1 != 0
$1 = 42
(( $1 != 0 && $1 != 3 )) is true only when $1 is not 0 and not 3:
(( $1 != 0 && $1 != 3 ))
$1
0
3
This statement is identical to ! (( $1 == 0 || $1 == 3 )), which also works correctly.
! (( $1 == 0 || $1 == 3 ))
None.
There was an error while loading. Please reload this page.