svn commit: r204836 - head/tools/regression/bin/sh/parser

Jilles Tjoelker jilles at FreeBSD.org
Sun Mar 7 15:08:43 UTC 2010


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))


More information about the svn-src-head mailing list