summary refs log tree commit diff
path: root/bin/cash/tests/expansion/set-u1.0
blob: 39f7e175432f909dd510d13ff9b41021f47e98c6 (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
# $FreeBSD: releng/12.0/bin/sh/tests/expansion/set-u1.0 213738 2010-10-12 18:20:38Z obrien $

${SH} -uc 'unset foo; echo $foo' 2>/dev/null && exit 1
${SH} -uc 'foo=; echo $foo' >/dev/null || exit 1
${SH} -uc 'foo=1; echo $foo' >/dev/null || exit 1
# -/+/= are unaffected by set -u
${SH} -uc 'unset foo; echo ${foo-}' >/dev/null || exit 1
${SH} -uc 'unset foo; echo ${foo+}' >/dev/null || exit 1
${SH} -uc 'unset foo; echo ${foo=}' >/dev/null || exit 1
# length/trimming are affected
${SH} -uc 'unset foo; echo ${#foo}' 2>/dev/null && exit 1
${SH} -uc 'foo=; echo ${#foo}' >/dev/null || exit 1
${SH} -uc 'unset foo; echo ${foo#?}' 2>/dev/null && exit 1
${SH} -uc 'foo=1; echo ${foo#?}' >/dev/null || exit 1
${SH} -uc 'unset foo; echo ${foo##?}' 2>/dev/null && exit 1
${SH} -uc 'foo=1; echo ${foo##?}' >/dev/null || exit 1
${SH} -uc 'unset foo; echo ${foo%?}' 2>/dev/null && exit 1
${SH} -uc 'foo=1; echo ${foo%?}' >/dev/null || exit 1
${SH} -uc 'unset foo; echo ${foo%%?}' 2>/dev/null && exit 1
${SH} -uc 'foo=1; echo ${foo%%?}' >/dev/null || exit 1

${SH} -uc 'echo $!' 2>/dev/null && exit 1
${SH} -uc ':& echo $!' >/dev/null || exit 1
${SH} -uc 'echo $#' >/dev/null || exit 1
${SH} -uc 'echo $1' 2>/dev/null && exit 1
${SH} -uc 'echo $1' ${SH} x >/dev/null || exit 1
${SH} -uc 'echo $2' ${SH} x 2>/dev/null && exit 1
${SH} -uc 'echo $2' ${SH} x y >/dev/null || exit 1
exit 0