set-u1.0 revision 198453
1# $FreeBSD: head/tools/regression/bin/sh/expansion/set-u1.0 198453 2009-10-24 20:57:11Z jilles $
2
3sh -uc 'unset foo; echo $foo' 2>/dev/null && exit 1
4sh -uc 'foo=; echo $foo' >/dev/null || exit 1
5sh -uc 'foo=1; echo $foo' >/dev/null || exit 1
6# -/+/= are unaffected by set -u
7sh -uc 'unset foo; echo ${foo-}' >/dev/null || exit 1
8sh -uc 'unset foo; echo ${foo+}' >/dev/null || exit 1
9sh -uc 'unset foo; echo ${foo=}' >/dev/null || exit 1
10# length/trimming are affected
11sh -uc 'unset foo; echo ${#foo}' 2>/dev/null && exit 1
12sh -uc 'foo=; echo ${#foo}' >/dev/null || exit 1
13sh -uc 'unset foo; echo ${foo#?}' 2>/dev/null && exit 1
14sh -uc 'foo=1; echo ${foo#?}' >/dev/null || exit 1
15sh -uc 'unset foo; echo ${foo##?}' 2>/dev/null && exit 1
16sh -uc 'foo=1; echo ${foo##?}' >/dev/null || exit 1
17sh -uc 'unset foo; echo ${foo%?}' 2>/dev/null && exit 1
18sh -uc 'foo=1; echo ${foo%?}' >/dev/null || exit 1
19sh -uc 'unset foo; echo ${foo%%?}' 2>/dev/null && exit 1
20sh -uc 'foo=1; echo ${foo%%?}' >/dev/null || exit 1
21
22sh -uc 'echo $!' 2>/dev/null && exit 1
23sh -uc ':& echo $!' >/dev/null || exit 1
24sh -uc 'echo $#' >/dev/null || exit 1
25sh -uc 'echo $1' 2>/dev/null && exit 1
26sh -uc 'echo $1' sh x >/dev/null || exit 1
27sh -uc 'echo $2' sh x 2>/dev/null && exit 1
28sh -uc 'echo $2' sh x y >/dev/null || exit 1
29exit 0
30