$NAME != "q" || $NAME != "Q"
Unless NAME can exist in a strange " Schrödinger's cat" sort of state where it can be both Q and q at the same time, this expression will always be true.
Think about it:
- If
NAME is neither q nor Q, both sub-expressions will be true so the full expression will be true.
- If it's
Q, then the first sub-expressions will be true, leading to the full expression being true as well.
- If it's
q, then the second sub-expressions will be true, leading to the full expression being true as well.
What you probably need is:
$NAME != "q" && $NAME != "Q"
Of course, if it's bash that you're using, it provides a way to uppercase and lowercase a string to make these comparisons easier:
while [[ "${NAME^^}" != "Q" ]] ; # upper-case variant
while [[ "${NAME,,}" != "q" ]] ; # lower-case variant
&&, not||. (This would behave identically in other languages, the error is purely logical.)