OT: case statements in sh

Jay R. Ashworth jra at baylink.com
Tue Jan 24 17:08:12 PST 2006


On Tue, Jan 24, 2006 at 07:15:45PM -0500, Bob Stockler wrote:
> | It will make your life a lot easier, both in reading the case statment,
> | and in extending it.
> | 
> | (as a special case (no pun intended, really) that particular example is
> | actually Duff's Device, and could be implemented thus:
> | 
> | echo enter a number:
> | read i
> | case $i in
> | 1)      echo "one"
> | 2)	echo "two"
> | 3)      echo "three"
> | 	;;
> | *)      echo "$i"
> | 	;;
> | esac
> | 
> | And would work the same way: cases fall-though in the shell just as
> | they do in C.)
> 
> And if you really get techincal about it, the final ";;"
> is not required (thought it looks pretty there, and makes
> things "look better".

It's not required by the interpreter.  But if you ever decide to
re-sort your case blocks, you'll discover that it's very handy indeed
to have around.  :-)

Cheers,
-- jra
-- 
Jay R. Ashworth                                                jra at baylink.com
Designer                          Baylink                             RFC 2100
Ashworth & Associates        The Things I Think                        '87 e24
St Petersburg FL USA      http://baylink.pitas.com             +1 727 647 1274

	A: No.
	Q: Should I include quotations after my message body?


More information about the Filepro-list mailing list