From owner-svn-src-stable@FreeBSD.ORG Sun Mar 28 19:34:57 2010 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EE7C3106566B; Sun, 28 Mar 2010 19:34:57 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DB5A68FC0A; Sun, 28 Mar 2010 19:34:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2SJYvrs022900; Sun, 28 Mar 2010 19:34:57 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2SJYvSq022890; Sun, 28 Mar 2010 19:34:57 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201003281934.o2SJYvSq022890@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 28 Mar 2010 19:34:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r205800 - in stable/8/tools/regression/bin/sh: builtins errors expansion parser X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Mar 2010 19:34:58 -0000 Author: jilles Date: Sun Mar 28 19:34:57 2010 New Revision: 205800 URL: http://svn.freebsd.org/changeset/base/205800 Log: MFC r196607,r198453,r204016,r204017,r204836,r204842,r205105,r205153 Various testcases that work correctly with stable/8 sh. Note: this creates some gaps in the numbering due to lower-numbered tests for new functionality which is not or not yet MFC'ed. Added: stable/8/tools/regression/bin/sh/builtins/eval3.0 - copied unchanged from r196607, head/tools/regression/bin/sh/builtins/eval3.0 stable/8/tools/regression/bin/sh/errors/redirection-error5.0 - copied unchanged from r205153, head/tools/regression/bin/sh/errors/redirection-error5.0 stable/8/tools/regression/bin/sh/expansion/arith3.0 - copied unchanged from r204017, head/tools/regression/bin/sh/expansion/arith3.0 stable/8/tools/regression/bin/sh/expansion/assign1.0 - copied unchanged from r204842, head/tools/regression/bin/sh/expansion/assign1.0 stable/8/tools/regression/bin/sh/expansion/cmdsubst2.0 - copied unchanged from r205105, head/tools/regression/bin/sh/expansion/cmdsubst2.0 stable/8/tools/regression/bin/sh/expansion/plus-minus1.0 - copied unchanged from r204842, head/tools/regression/bin/sh/expansion/plus-minus1.0 stable/8/tools/regression/bin/sh/expansion/question1.0 - copied unchanged from r198453, head/tools/regression/bin/sh/expansion/question1.0 stable/8/tools/regression/bin/sh/expansion/set-u1.0 - copied unchanged from r198453, head/tools/regression/bin/sh/expansion/set-u1.0 stable/8/tools/regression/bin/sh/parser/heredoc1.0 - copied unchanged from r204836, head/tools/regression/bin/sh/parser/heredoc1.0 Modified: stable/8/tools/regression/bin/sh/expansion/arith2.0 Directory Properties: stable/8/tools/regression/bin/sh/ (props changed) Copied: stable/8/tools/regression/bin/sh/builtins/eval3.0 (from r196607, head/tools/regression/bin/sh/builtins/eval3.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/eval3.0 Sun Mar 28 19:34:57 2010 (r205800, copy of r196607, head/tools/regression/bin/sh/builtins/eval3.0) @@ -0,0 +1,9 @@ +# $FreeBSD$ + +eval 'false;' && exit 1 +eval 'true;' || exit 1 +eval 'false; +' && exit 1 +eval 'true; +' || exit 1 +exit 0 Copied: stable/8/tools/regression/bin/sh/errors/redirection-error5.0 (from r205153, head/tools/regression/bin/sh/errors/redirection-error5.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/errors/redirection-error5.0 Sun Mar 28 19:34:57 2010 (r205800, copy of r205153, head/tools/regression/bin/sh/errors/redirection-error5.0) @@ -0,0 +1,5 @@ +# $FreeBSD$ +# A redirection error on a subshell should not abort the shell. +exec 2>/dev/null +( echo bad ) 0)) Copied: stable/8/tools/regression/bin/sh/expansion/plus-minus1.0 (from r204842, head/tools/regression/bin/sh/expansion/plus-minus1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/expansion/plus-minus1.0 Sun Mar 28 19:34:57 2010 (r205800, copy of r204842, head/tools/regression/bin/sh/expansion/plus-minus1.0) @@ -0,0 +1,81 @@ +# $FreeBSD$ + +e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' +h='##' +failures='' +ok='' + +testcase() { + code="$1" + expected="$2" + oIFS="$IFS" + eval "$code" + IFS='|' + result="$#|$*" + IFS="$oIFS" + if [ "x$result" = "x$expected" ]; then + ok=x$ok + else + failures=x$failures + echo "For $code, expected $expected actual $result" + fi +} + +testcase 'set -- a b' '2|a|b' +testcase 'set --' '0|' +testcase 'set -- ${e}' '0|' +testcase 'set -- "${e}"' '1|' + +testcase 'set -- $p' '1|/etc/' +testcase 'set -- "$p"' '1|/et[c]/' +testcase 'set -- ${s+$p}' '1|/etc/' +testcase 'set -- "${s+$p}"' '1|/et[c]/' +testcase 'set -- ${s+"$p"}' '1|/et[c]/' +# Dquotes in dquotes is undefined for Bourne shell operators +#testcase 'set -- "${s+"$p"}"' '1|/et[c]/' +testcase 'set -- ${e:-$p}' '1|/etc/' +testcase 'set -- "${e:-$p}"' '1|/et[c]/' +testcase 'set -- ${e:-"$p"}' '1|/et[c]/' +# Dquotes in dquotes is undefined for Bourne shell operators +#testcase 'set -- "${e:-"$p"}"' '1|/et[c]/' +testcase 'set -- ${e:+"$e"}' '0|' +testcase 'set -- ${e:+$w"$e"}' '0|' +testcase 'set -- ${w:+"$w"}' '1|a b c' +testcase 'set -- ${w:+$w"$w"}' '3|a|b|ca b c' + +# These two are known broken in FreeBSD /bin/sh +#testcase 'set -- ${s+a b}' '2|a|b' +#testcase 'set -- ${e:-a b}' '2|a|b' +testcase 'set -- "${s+a b}"' '1|a b' +testcase 'set -- "${e:-a b}"' '1|a b' +testcase 'set -- ${e:-\}}' '1|}' +# Currently broken in FreeBSD /bin/sh +#testcase 'set -- "${e:-\}}"' '1|}' +testcase 'set -- ${e:+{}}' '1|}' +testcase 'set -- "${e:+{}}"' '1|}' + +testcase 'set -- ${e+x}${e+x}' '1|xx' +testcase 'set -- "${e+x}"${e+x}' '1|xx' +testcase 'set -- ${e+x}"${e+x}"' '1|xx' +testcase 'set -- "${e+x}${e+x}"' '1|xx' +testcase 'set -- "${e+x}""${e+x}"' '1|xx' + +testcase 'set -- ${e:-${e:-$p}}' '1|/etc/' +testcase 'set -- "${e:-${e:-$p}}"' '1|/et[c]/' +testcase 'set -- ${e:-"${e:-$p}"}' '1|/et[c]/' +testcase 'set -- ${e:-${e:-"$p"}}' '1|/et[c]/' +testcase 'set -- ${e:-${e:-${e:-$w}}}' '3|a|b|c' +testcase 'set -- ${e:-${e:-${e:-"$w"}}}' '1|a b c' +testcase 'set -- ${e:-${e:-"${e:-$w}"}}' '1|a b c' +testcase 'set -- ${e:-"${e:-${e:-$w}}"}' '1|a b c' +testcase 'set -- "${e:-${e:-${e:-$w}}}"' '1|a b c' + +testcase 'shift $#; set -- ${1+"$@"}' '0|' +testcase 'set -- ""; set -- ${1+"$@"}' '1|' +testcase 'set -- "" a; set -- ${1+"$@"}' '2||a' +testcase 'set -- a ""; set -- ${1+"$@"}' '2|a|' +testcase 'set -- a b; set -- ${1+"$@"}' '2|a|b' +testcase 'set -- a\ b; set -- ${1+"$@"}' '1|a b' +testcase 'set -- " " ""; set -- ${1+"$@"}' '2| |' + +test "x$failures" = x Copied: stable/8/tools/regression/bin/sh/expansion/question1.0 (from r198453, head/tools/regression/bin/sh/expansion/question1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/expansion/question1.0 Sun Mar 28 19:34:57 2010 (r205800, copy of r198453, head/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 Copied: stable/8/tools/regression/bin/sh/expansion/set-u1.0 (from r198453, head/tools/regression/bin/sh/expansion/set-u1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/expansion/set-u1.0 Sun Mar 28 19:34:57 2010 (r205800, copy of r198453, head/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 Copied: stable/8/tools/regression/bin/sh/parser/heredoc1.0 (from r204836, head/tools/regression/bin/sh/parser/heredoc1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/parser/heredoc1.0 Sun Mar 28 19:34:57 2010 (r205800, copy of r204836, head/tools/regression/bin/sh/parser/heredoc1.0) @@ -0,0 +1,85 @@ +# $FreeBSD$ + +failures=0 + +check() { + if ! eval "[ $* ]"; then + echo "Failed: $*" + : $((failures += 1)) + fi +} + +check '"$(cat <