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