Reading POSIX specification for case conditional construct, I see:
case word in [(]pattern1) compound-list;; [[(]pattern[ | pattern] ... ) compound-list;;] ... [[(]pattern[ | pattern] ... ) compound-list] esac
As I understand, there will be at least one condition in body of
case, and the
compound-list corresponded with that condition must be existed.
I wrote a quick test:
$ cat test.sh case $1 in esac case $1 in .) ;; *) echo 1 esac
$ for shell in /bin/*sh; do printf '=%-18s=\n' "$shell" "$shell" ./test.sh . done =/bin/ash = =/bin/bash = =/bin/dash = =/bin/heirloom-sh = =/bin/ksh = =/bin/lksh = =/bin/mksh = =/bin/pdksh = =/bin/posh = =/bin/schily-osh = =/bin/schily-sh = =/bin/sh = =/bin/yash = =/bin/zsh =
It surprised me! All my known shells accepted the syntax. And also:
case $1 in esac
work in all shells above but
ksh93u+ in my system), although it worked in
ksh88 as confirmed by schily.
So is it allowed by POSIX or I missed something?