summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2009-10-24 20:57:11 +0000
committerjilles <jilles@FreeBSD.org>2009-10-24 20:57:11 +0000
commit78d7070a590cfdd525d736fd6bd44f7939cb200b (patch)
tree3c1dcc57772756c665b1e8cd148427d284f4c2c1 /tools
parentb15a68a1be97102be434b632731a2f5a5f9c7c9d (diff)
downloadFreeBSD-src-78d7070a590cfdd525d736fd6bd44f7939cb200b.zip
FreeBSD-src-78d7070a590cfdd525d736fd6bd44f7939cb200b.tar.gz
Add some tests for ${var?} and set -u.
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/expansion/question1.022
-rw-r--r--tools/regression/bin/sh/expansion/set-u1.029
2 files changed, 51 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/expansion/question1.0 b/tools/regression/bin/sh/expansion/question1.0
new file mode 100644
index 0000000..355af62
--- /dev/null
+++ b/tools/regression/bin/sh/expansion/question1.0
@@ -0,0 +1,22 @@
+# $FreeBSD$
+
+x=a\ b
+[ "$x" = "${x?}" ] || exit 1
+set -- ${x?}
+{ [ "$#" = 2 ] && [ "$1" = a ] && [ "$2" = b ]; } || exit 1
+unset x
+(echo ${x?abcdefg}) 2>&1 | grep -q abcdefg || exit 1
+sh -c 'unset foo; echo ${foo?}' 2>/dev/null && exit 1
+sh -c 'foo=; echo ${foo:?}' 2>/dev/null && exit 1
+sh -c 'foo=; echo ${foo?}' >/dev/null || exit 1
+sh -c 'foo=1; echo ${foo:?}' >/dev/null || exit 1
+sh -c 'echo ${!?}' 2>/dev/null && exit 1
+sh -c ':& echo ${!?}' >/dev/null || exit 1
+sh -c 'echo ${#?}' >/dev/null || exit 1
+sh -c 'echo ${*?}' 2>/dev/null && exit 1
+sh -c 'echo ${*?}' sh x >/dev/null || exit 1
+sh -c 'echo ${1?}' 2>/dev/null && exit 1
+sh -c 'echo ${1?}' sh x >/dev/null || exit 1
+sh -c 'echo ${2?}' sh x 2>/dev/null && exit 1
+sh -c 'echo ${2?}' sh x y >/dev/null || exit 1
+exit 0
diff --git a/tools/regression/bin/sh/expansion/set-u1.0 b/tools/regression/bin/sh/expansion/set-u1.0
new file mode 100644
index 0000000..a66bfc9
--- /dev/null
+++ b/tools/regression/bin/sh/expansion/set-u1.0
@@ -0,0 +1,29 @@
+# $FreeBSD$
+
+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
OpenPOWER on IntegriCloud