OT: case statements in sh

Kenneth Brody kenbrody at bestweb.net
Tue Jan 24 18:50:00 PST 2006


[...]
> > | 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".
[...]

My copy of bash 1.14.7(1) won't allow the above syntax.  It requires ";;"
between each case.

==========
case "$1" in
  1) echo one
  2) echo two
  3) echo three
  *) echo default
esac
==========
/tmp/foo.sh: syntax error near unexpected token `2)'
/tmp/foo.sh: /tmp/foo.sh: line 3: `  2) echo two'
==========

--
KenBrody at BestWeb dot net        spamtrap: <g8ymh8uf001 at sneakemail.com>
http://www.hvcomputer.com
http://www.fileProPlus.com


More information about the Filepro-list mailing list