[opensuse] BASH: Shorter way to do [[ $line == QUIT ]] || [[ $line == Quit ]] || [[ $line == quit ]] && break ?



Bash gurus,

What is a shorter way to do multiple case insensitive tests on a string or variable that would accomplish this:

[[ $line == QUIT ]] || [[ $line == Quit ]] || [[ $line == quit ]] && break

Basically what I am looking for is some case insensitive way to test for quit or exit without having to define a test for each possible permutation without bringing in a big hammer like sed or the like. I am a bit confused on the test expansion but know things like $line == [Qq]uit won't work.

I can do it in case:

case $line in
[Qq][Uu][Ii][Tt] ) break;;
esac

But that seems like a clunky use of case. Is there a better way?


--
David C. Rankin, J.D.,P.E.
Rankin Law Firm, PLLC
510 Ochiltree Street
Nacogdoches, Texas 75961
Telephone: (936) 715-9333
Facsimile: (936) 715-9339
www.rankinlawfirm.com
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx



Relevant Pages


Loading