xref: /freebsd/bin/sh/tests/parser/case1.0 (revision 734e82fe33aa764367791a7d603b383996c6b40b)
1
2keywords='if then else elif fi while until for do done { } case esac ! in'
3
4# Keywords can be used unquoted in case statements, except the keyword
5# esac as the first pattern of a '|' alternation without a starting '('.
6# (POSIX doesn't seem to require (esac) to work.)
7for k in $keywords; do
8	eval "case $k in (foo|$k) ;; *) echo bad ;; esac"
9	eval "case $k in ($k) ;; *) echo bad ;; esac"
10	eval "case $k in foo|$k) ;; *) echo bad ;; esac"
11	[ "$k" = esac ] && continue
12	eval "case $k in $k) ;; *) echo bad ;; esac"
13done
14