summary refs log tree commit diff
path: root/bin/1sh/tests/builtins/case9.0
blob: b415fb02709ae72b6a7a419612fc15ff3c764492 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# $FreeBSD: releng/12.1/bin/sh/tests/builtins/case9.0 223186 2011-06-17 13:03:49Z jilles $

errors=0

f() {
	result=
	case $1 in
	a) result=${result}a ;;
	b) result=${result}b ;&
	c) result=${result}c ;&
	d) result=${result}d ;;
	e) result=${result}e ;&
	esac
}

check() {
	f "$1"
	if [ "$result" != "$2" ]; then
		printf "For %s, expected %s got %s\n" "$1" "$2" "$result"
		errors=$((errors + 1))
	fi
}

check '' ''
check a a
check b bcd
check c cd
check d d
check e e

if ! (case 1 in
	1) false ;&
	2) true ;;
esac) then
	echo "Subshell bad"
	errors=$((errors + 1))
fi

exit $((errors != 0))