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