You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vidar Holen edited this page May 17, 2025
·
1 revision
You probably wanted || here, otherwise it's always false.
Problematic code:
if(( ret ==137&& ret ==143))thenecho"Process killed by SIGTERM/SIGKILL"fi
Correct code:
if(( ret ==137|| ret ==143))thenecho"Process killed by SIGTERM/SIGKILL"fi
Rationale:
The problematic condition will never trigger because of a logic error.
In English one think say "I want to check for the numbers 137 and 143", but the test ends up checking that the number is both 137 and 143 at the same time, which it can't be (if the number is 137, it necessarily won't be 143, and vice versa).
The correct check is "if the number is 137 or if the number is 143", which will be true if the value is either 137 or 143.
Exceptions:
None
Related resources:
Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!