xref: /freebsd/bin/sh/tests/parser/case1.0 (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
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