]> git.saurik.com Git - apple/shell_cmds.git/blob - sh/tests/builtins/case9.0
shell_cmds-216.60.1.tar.gz
[apple/shell_cmds.git] / sh / tests / builtins / case9.0
1 # $FreeBSD: head/bin/sh/tests/builtins/case9.0 223186 2011-06-17 13:03:49Z jilles $
2
3 errors=0
4
5 f() {
6 result=
7 case $1 in
8 a) result=${result}a ;;
9 b) result=${result}b ;&
10 c) result=${result}c ;&
11 d) result=${result}d ;;
12 e) result=${result}e ;&
13 esac
14 }
15
16 check() {
17 f "$1"
18 if [ "$result" != "$2" ]; then
19 printf "For %s, expected %s got %s\n" "$1" "$2" "$result"
20 errors=$((errors + 1))
21 fi
22 }
23
24 check '' ''
25 check a a
26 check b bcd
27 check c cd
28 check d d
29 check e e
30
31 if ! (case 1 in
32 1) false ;&
33 2) true ;;
34 esac) then
35 echo "Subshell bad"
36 errors=$((errors + 1))
37 fi
38
39 exit $((errors != 0))