1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 # $FreeBSD: src/tools/regression/bin/sh/expansion/set-u1.0,v 1.2 2010/10/12 18:20:38 obrien Exp $
16 ${THIS_SH} -uc 'unset foo; echo ${foo}' 2>/dev/null && exit 1
17 ${THIS_SH} -uc 'unset foo; echo $foo' 2>/dev/null && exit 1
18 ${THIS_SH} -uc 'foo=; echo $foo' >/dev/null || exit 2
19 ${THIS_SH} -uc 'foo=1; echo $foo' >/dev/null || exit 3
20 # -/+/= are unaffected by set -u
21 ${THIS_SH} -uc 'unset foo; echo ${foo-}' >/dev/null || exit 4
22 ${THIS_SH} -uc 'unset foo; echo ${foo+}' >/dev/null || exit 5
23 ${THIS_SH} -uc 'unset foo; echo ${foo=}' >/dev/null || exit 6
24 # length/trimming are affected
25 ${THIS_SH} -uc 'unset foo; echo ${#foo}' 2>/dev/null && exit 7
26 ${THIS_SH} -uc 'foo=; echo ${#foo}' >/dev/null || exit 8
27 ${THIS_SH} -uc 'unset foo; echo ${foo#?}' 2>/dev/null && exit 9
28 ${THIS_SH} -uc 'foo=1; echo ${foo#?}' >/dev/null || exit 10
29 ${THIS_SH} -uc 'unset foo; echo ${foo##?}' 2>/dev/null && exit 11
30 ${THIS_SH} -uc 'foo=1; echo ${foo##?}' >/dev/null || exit 12
31 ${THIS_SH} -uc 'unset foo; echo ${foo%?}' 2>/dev/null && exit 13
32 ${THIS_SH} -uc 'foo=1; echo ${foo%?}' >/dev/null || exit 14
33 ${THIS_SH} -uc 'unset foo; echo ${foo%%?}' 2>/dev/null && exit 15
34 ${THIS_SH} -uc 'foo=1; echo ${foo%%?}' >/dev/null || exit 16
36 ${THIS_SH} -uc 'echo $!' 2>/dev/null && exit 17
37 ${THIS_SH} -uc ':& echo $!' >/dev/null || exit 18
38 ${THIS_SH} -uc 'echo $#' >/dev/null || exit 19
39 ${THIS_SH} -uc 'echo $1' 2>/dev/null && exit 20
40 ${THIS_SH} -uc 'echo $1' ${THIS_SH} xnotthere >/dev/null || exit 21
41 ${THIS_SH} -uc 'echo $2' ${THIS_SH} xnotthere 2>/dev/null && exit 22
42 ${THIS_SH} -uc 'echo $2' ${THIS_SH} xnotthere ynotthere >/dev/null || exit 23
44 ${THIS_SH} -uc 'echo $! ; exit 24' 2>/dev/null
45 ${THIS_SH} -uc 'echo ${!} ; exit 25' 2>/dev/null
46 ${THIS_SH} -uc 'echo ${!,} ; exit 26' 2>/dev/null
48 ${THIS_SH} -uc 'echo ${!-ok 27} >/dev/null || exit 27'
49 ${THIS_SH} -uc 'echo ${2-ok 28} >/dev/null || exit 28'