opnsense-src/tools/regression/bin/sh/builtins/case9.0
Jilles Tjoelker c9afaa6389 sh: Add case statement fallthrough (with ';&' instead of ';;').
Replacing ;; with the new control operator ;& will cause the next list to be
executed as well without checking its pattern, continuing until a list ends
with ;; or until the end of the case statement. This is like omitting
"break" in a C "switch" statement.

The sequence ;& was formerly invalid.

This feature is proposed for the next POSIX issue in Austin Group issue
#449.
2011-06-17 13:03:49 +00:00

39 lines
515 B
Text

# $FreeBSD$
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))