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