Date: Sat, 24 Oct 2009 20:57:12 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r198453 - head/tools/regression/bin/sh/expansion Message-ID: <200910242057.n9OKvC2v011665@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Sat Oct 24 20:57:11 2009 New Revision: 198453 URL: http://svn.freebsd.org/changeset/base/198453 Log: Add some tests for ${var?} and set -u. Added: head/tools/regression/bin/sh/expansion/question1.0 (contents, props changed) head/tools/regression/bin/sh/expansion/set-u1.0 (contents, props changed) Added: head/tools/regression/bin/sh/expansion/question1.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/expansion/question1.0 Sat Oct 24 20:57:11 2009 (r198453) @@ -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 Added: head/tools/regression/bin/sh/expansion/set-u1.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/expansion/set-u1.0 Sat Oct 24 20:57:11 2009 (r198453) @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910242057.n9OKvC2v011665>