Date: Sun, 7 Mar 2010 15:08:42 +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: r204836 - head/tools/regression/bin/sh/parser Message-ID: <201003071508.o27F8gTg082547@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Sun Mar 7 15:08:42 2010 New Revision: 204836 URL: http://svn.freebsd.org/changeset/base/204836 Log: sh: Add various testcases for here documents. They are mainly about expansions in here documents but because all the testcases are in $() command substitution, we also test that $() command substitution is recursively parsed (or very close to it). Added: head/tools/regression/bin/sh/parser/heredoc1.0 (contents, props changed) Added: head/tools/regression/bin/sh/parser/heredoc1.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/parser/heredoc1.0 Sun Mar 7 15:08:42 2010 (r204836) @@ -0,0 +1,85 @@ +# $FreeBSD$ + +failures=0 + +check() { + if ! eval "[ $* ]"; then + echo "Failed: $*" + : $((failures += 1)) + fi +} + +check '"$(cat <<EOF +hi +EOF +)" = hi' + +check '"$(cat <<EOF +${$+hi} +EOF +)" = hi' + +unset yy +check '"$(cat <<EOF +${yy-hi} +EOF +)" = hi' + +check '"$(cat <<EOF +${$+hi +there} +EOF +)" = "hi +there"' + +check '"$(cat <<EOF +$((1+1)) +EOF +)" = 2' + +check '"$(cat <<EOF +$(echo hi) +EOF +)" = hi' + +check '"$(cat <<EOF +`echo hi` +EOF +)" = hi' + +check '"$(cat <<\EOF +${$+hi} +EOF +)" = "\${\$+hi}"' + +check '"$(cat <<\EOF +$( +EOF +)" = \$\(' + +check '"$(cat <<\EOF +` +EOF +)" = \`' + +check '"$(cat <<EOF +" +EOF +)" = \"' + +check '"$(cat <<\EOF +" +EOF +)" = \"' + +check '"$(cat <<esac +'"'"' +esac +)" = "'"'"'"' + +check '"$(cat <<\) +'"'"' +) +)" = "'"'"'"' + +exit $((failures != 0))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003071508.o27F8gTg082547>