Wednesday, June 16, 2010

Just in case

I just learned something new about shell syntax -- specifically, about the case statement.

The shell's big enough that I expect I'll be able to keep learning things about it for a long time, even though I've been writing shell scripts for ... lessee ... about 30 years.

Here's today's:

I'm used to writing this:
case $key in
whatever) do-something ;;
*) some-default-behavior ;;
I just read a Fedora system script that looks like this, instead:
case $key in
(whatever) do-something ;;
(*) some-default-behavior ;;
The leading paren is optional, but legal. And not just for bash, but for any POSIX shell. Amazing. Also, the last item doesn't have to have the semis, so it could even be this:
case $key in
(whatever) do-something ;;
(*) some-default-behavior


Anonymous said...

Work For Advertising Company at

Join one of the best Advertising Company of India. We pay you for your hard work. 100% Payment Assurance. Its a copy-paste work. Unlimited Monthly income.
For more details: E-mail us at Website:

謝佑芝 said...

IS VERY GOOD..............................