Date: Tue, 14 Jun 2011 20:04:23 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r223096 - in stable/8/tools/regression/bin/sh: builtins execution expansion parameters parser Message-ID: <201106142004.p5EK4N6G049664@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Tue Jun 14 20:04:23 2011 New Revision: 223096 URL: http://svn.freebsd.org/changeset/base/223096 Log: MFC r221887,r222158,r222379,r222451,r222512,r222661,r222715,r222882: sh: New testcases that already work in stable/8. Added: stable/8/tools/regression/bin/sh/builtins/cd5.0 - copied unchanged from r222379, head/tools/regression/bin/sh/builtins/cd5.0 stable/8/tools/regression/bin/sh/builtins/set1.0 - copied unchanged from r222451, head/tools/regression/bin/sh/builtins/set1.0 stable/8/tools/regression/bin/sh/execution/set-n1.0 - copied unchanged from r222661, head/tools/regression/bin/sh/execution/set-n1.0 stable/8/tools/regression/bin/sh/execution/set-n2.0 - copied unchanged from r222661, head/tools/regression/bin/sh/execution/set-n2.0 stable/8/tools/regression/bin/sh/execution/set-n3.0 - copied unchanged from r222661, head/tools/regression/bin/sh/execution/set-n3.0 stable/8/tools/regression/bin/sh/execution/set-x1.0 - copied unchanged from r222882, head/tools/regression/bin/sh/execution/set-x1.0 stable/8/tools/regression/bin/sh/execution/set-x2.0 - copied unchanged from r222882, head/tools/regression/bin/sh/execution/set-x2.0 stable/8/tools/regression/bin/sh/expansion/heredoc1.0 - copied unchanged from r222715, head/tools/regression/bin/sh/expansion/heredoc1.0 stable/8/tools/regression/bin/sh/parameters/positional1.0 - copied unchanged from r222158, head/tools/regression/bin/sh/parameters/positional1.0 stable/8/tools/regression/bin/sh/parser/func2.0 - copied unchanged from r222512, head/tools/regression/bin/sh/parser/func2.0 stable/8/tools/regression/bin/sh/parser/func3.0 - copied unchanged from r222512, head/tools/regression/bin/sh/parser/func3.0 stable/8/tools/regression/bin/sh/parser/heredoc10.0 - copied unchanged from r221887, head/tools/regression/bin/sh/parser/heredoc10.0 stable/8/tools/regression/bin/sh/parser/heredoc9.0 - copied unchanged from r221887, head/tools/regression/bin/sh/parser/heredoc9.0 Modified: Directory Properties: stable/8/tools/regression/bin/sh/ (props changed) Copied: stable/8/tools/regression/bin/sh/builtins/cd5.0 (from r222379, head/tools/regression/bin/sh/builtins/cd5.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/cd5.0 Tue Jun 14 20:04:23 2011 (r223096, copy of r222379, head/tools/regression/bin/sh/builtins/cd5.0) @@ -0,0 +1,23 @@ +# $FreeBSD$ + +set -e +T=$(mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXX") +trap 'rm -rf "$T"' 0 + +cd -P "$T" +D=$(pwd) + +mkdir a a/1 b b/1 b/2 + +CDPATH=$D/a: +# Basic test. +cd 1 >/dev/null +[ "$(pwd)" = "$D/a/1" ] +# Test that the current directory is not checked before CDPATH. +cd "$D/b" +cd 1 >/dev/null +[ "$(pwd)" = "$D/a/1" ] +# Test not using a CDPATH entry. +cd "$D/b" +cd 2 +[ "$(pwd)" = "$D/b/2" ] Copied: stable/8/tools/regression/bin/sh/builtins/set1.0 (from r222451, head/tools/regression/bin/sh/builtins/set1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/set1.0 Tue Jun 14 20:04:23 2011 (r223096, copy of r222451, head/tools/regression/bin/sh/builtins/set1.0) @@ -0,0 +1,32 @@ +# $FreeBSD$ + +set +C +set +f +set -e + +settings=$(set +o) +set -C +set -f +set +e +case $- in +*C*) ;; +*) echo missing C ;; +esac +case $- in +*f*) ;; +*) echo missing C ;; +esac +case $- in +*e*) echo bad e ;; +esac +eval "$settings" +case $- in +*C*) echo bad C ;; +esac +case $- in +*f*) echo bad f ;; +esac +case $- in +*e*) ;; +*) echo missing e ;; +esac Copied: stable/8/tools/regression/bin/sh/execution/set-n1.0 (from r222661, head/tools/regression/bin/sh/execution/set-n1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/execution/set-n1.0 Tue Jun 14 20:04:23 2011 (r223096, copy of r222661, head/tools/regression/bin/sh/execution/set-n1.0) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +v=$( ($SH -n <<'EOF' +for +EOF +) 2>&1 >/dev/null) +[ $? -ne 0 ] && [ -n "$v" ] Copied: stable/8/tools/regression/bin/sh/execution/set-n2.0 (from r222661, head/tools/regression/bin/sh/execution/set-n2.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/execution/set-n2.0 Tue Jun 14 20:04:23 2011 (r223096, copy of r222661, head/tools/regression/bin/sh/execution/set-n2.0) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +$SH -n <<'EOF' +echo bad +EOF Copied: stable/8/tools/regression/bin/sh/execution/set-n3.0 (from r222661, head/tools/regression/bin/sh/execution/set-n3.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/execution/set-n3.0 Tue Jun 14 20:04:23 2011 (r223096, copy of r222661, head/tools/regression/bin/sh/execution/set-n3.0) @@ -0,0 +1,4 @@ +# $FreeBSD$ + +v=$( ($SH -nc 'for') 2>&1 >/dev/null) +[ $? -ne 0 ] && [ -n "$v" ] Copied: stable/8/tools/regression/bin/sh/execution/set-x1.0 (from r222882, head/tools/regression/bin/sh/execution/set-x1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/execution/set-x1.0 Tue Jun 14 20:04:23 2011 (r223096, copy of r222882, head/tools/regression/bin/sh/execution/set-x1.0) @@ -0,0 +1,8 @@ +# $FreeBSD$ + +key='must_contain_this' +{ r=`set -x; { : "$key"; } 2>&1 >/dev/null`; } 2>/dev/null +case $r in +*"$key"*) true ;; +*) false ;; +esac Copied: stable/8/tools/regression/bin/sh/execution/set-x2.0 (from r222882, head/tools/regression/bin/sh/execution/set-x2.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/execution/set-x2.0 Tue Jun 14 20:04:23 2011 (r223096, copy of r222882, head/tools/regression/bin/sh/execution/set-x2.0) @@ -0,0 +1,9 @@ +# $FreeBSD$ + +key='must contain this' +PS4="$key+ " +{ r=`set -x; { :; } 2>&1 >/dev/null`; } 2>/dev/null +case $r in +*"$key"*) true ;; +*) false ;; +esac Copied: stable/8/tools/regression/bin/sh/expansion/heredoc1.0 (from r222715, head/tools/regression/bin/sh/expansion/heredoc1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/expansion/heredoc1.0 Tue Jun 14 20:04:23 2011 (r223096, copy of r222715, head/tools/regression/bin/sh/expansion/heredoc1.0) @@ -0,0 +1,25 @@ +# $FreeBSD$ + +f() { return $1; } + +[ `f 42; { cat; } <<EOF +$? +EOF +` = 42 ] || echo compound command bad + +[ `f 42; (cat) <<EOF +$? +EOF +` = 42 ] || echo subshell bad + +long=`printf %08192d 0` + +[ `f 42; { cat; } <<EOF +$long.$? +EOF +` = $long.42 ] || echo long compound command bad + +[ `f 42; (cat) <<EOF +$long.$? +EOF +` = $long.42 ] || echo long subshell bad Copied: stable/8/tools/regression/bin/sh/parameters/positional1.0 (from r222158, head/tools/regression/bin/sh/parameters/positional1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/parameters/positional1.0 Tue Jun 14 20:04:23 2011 (r223096, copy of r222158, head/tools/regression/bin/sh/parameters/positional1.0) @@ -0,0 +1,13 @@ +# $FreeBSD$ + +set -- a b c d e f g h i j +[ "$1" = a ] || echo "error at line $LINENO" +[ "${1}" = a ] || echo "error at line $LINENO" +[ "${1-foo}" = a ] || echo "error at line $LINENO" +[ "${1+foo}" = foo ] || echo "error at line $LINENO" +[ "$1+foo" = a+foo ] || echo "error at line $LINENO" +[ "$10" = a0 ] || echo "error at line $LINENO" +[ "$100" = a00 ] || echo "error at line $LINENO" +[ "${10}" = j ] || echo "error at line $LINENO" +[ "${10-foo}" = j ] || echo "error at line $LINENO" +[ "${100-foo}" = foo ] || echo "error at line $LINENO" Copied: stable/8/tools/regression/bin/sh/parser/func2.0 (from r222512, head/tools/regression/bin/sh/parser/func2.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/parser/func2.0 Tue Jun 14 20:04:23 2011 (r223096, copy of r222512, head/tools/regression/bin/sh/parser/func2.0) @@ -0,0 +1,6 @@ +# $FreeBSD$ + +f() { return 42; } +f() { return 3; } & +f +[ $? -eq 42 ] Copied: stable/8/tools/regression/bin/sh/parser/func3.0 (from r222512, head/tools/regression/bin/sh/parser/func3.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/parser/func3.0 Tue Jun 14 20:04:23 2011 (r223096, copy of r222512, head/tools/regression/bin/sh/parser/func3.0) @@ -0,0 +1,6 @@ +# $FreeBSD$ + +name=/var/empty/nosuch +f() { true; } <$name +name=/dev/null +f Copied: stable/8/tools/regression/bin/sh/parser/heredoc10.0 (from r221887, head/tools/regression/bin/sh/parser/heredoc10.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/parser/heredoc10.0 Tue Jun 14 20:04:23 2011 (r223096, copy of r221887, head/tools/regression/bin/sh/parser/heredoc10.0) @@ -0,0 +1,49 @@ +# $FreeBSD$ + +# It may be argued that +# x=$(cat <<EOF +# foo +# EOF) +# is a valid complete command that sets x to foo, because +# cat <<EOF +# foo +# EOF +# is a valid script even without the final newline. +# However, if the here-document is not within a new-style command substitution +# or there are other constructs nested inside the command substitution that +# need terminators, the delimiter at the start of a line followed by a close +# parenthesis is clearly a literal part of the here-document. + +# This file contains tests that may not work with simplistic $(...) parsers. +# The open parentheses in comments help mksh, but not zsh. + +failures=0 + +check() { + if ! eval "[ $* ]"; then + echo "Failed: $*" + : $((failures += 1)) + fi +} + +check '"$(cat <<EOF # ( +EOF ) +EOF +)" = "EOF )"' + +check '"$({ cat <<EOF # ( +EOF) +EOF +})" = "EOF)"' + +check '"$(if :; then cat <<EOF # ( +EOF) +EOF +fi)" = "EOF)"' + +check '"$( (cat <<EOF # ( +EOF) +EOF +))" = "EOF)"' + +exit $((failures != 0)) Copied: stable/8/tools/regression/bin/sh/parser/heredoc9.0 (from r221887, head/tools/regression/bin/sh/parser/heredoc9.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/parser/heredoc9.0 Tue Jun 14 20:04:23 2011 (r223096, copy of r221887, head/tools/regression/bin/sh/parser/heredoc9.0) @@ -0,0 +1,58 @@ +# $FreeBSD$ + +# It may be argued that +# x=$(cat <<EOF +# foo +# EOF) +# is a valid complete command that sets x to foo, because +# cat <<EOF +# foo +# EOF +# is a valid script even without the final newline. +# However, if the here-document is not within a new-style command substitution +# or there are other constructs nested inside the command substitution that +# need terminators, the delimiter at the start of a line followed by a close +# parenthesis is clearly a literal part of the here-document. + +# This file contains tests that also work with simplistic $(...) parsers. + +failures=0 + +check() { + if ! eval "[ $* ]"; then + echo "Failed: $*" + : $((failures += 1)) + fi +} + +check '`${SH} -c "cat <<EOF +EOF) +EOF +"` = "EOF)"' + +check '`${SH} -c "(cat <<EOF +EOF) +EOF +)"` = "EOF)"' + +check '"`cat <<EOF +EOF x +EOF +`" = "EOF x"' + +check '"`cat <<EOF +EOF ) +EOF +`" = "EOF )"' + +check '"`cat <<EOF +EOF) +EOF +`" = "EOF)"' + +check '"$(cat <<EOF +EOF x +EOF +)" = "EOF x"' + +exit $((failures != 0))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106142004.p5EK4N6G049664>