Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Jun 2009 22:15:59 +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: r194517 - in head/tools/regression/bin/sh: builtins errors
Message-ID:  <200906192215.n5JMFxtt056887@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Fri Jun 19 22:15:59 2009
New Revision: 194517
URL: http://svn.freebsd.org/changeset/base/194517

Log:
  Add tests for r194406 and r194516.
  
  Approved by:	ed (mentor)

Added:
  head/tools/regression/bin/sh/builtins/trap2.0   (contents, props changed)
  head/tools/regression/bin/sh/errors/backquote-error1.0   (contents, props changed)

Added: head/tools/regression/bin/sh/builtins/trap2.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/builtins/trap2.0	Fri Jun 19 22:15:59 2009	(r194517)
@@ -0,0 +1,52 @@
+# $FreeBSD$
+# This is really a test for outqstr(), which is readily accessible via trap.
+
+runtest()
+{
+	teststring=$1
+	trap -- "$teststring" USR1
+	traps=$(trap)
+	if [ "$teststring" != "-" ] && [ -z "$traps" ]; then
+		# One possible reading of POSIX requires the above to return an
+		# empty string because backquote commands are executed in a
+		# subshell and subshells shall reset traps. However, an example
+		# in the normative description of the trap builtin shows the
+		# same usage as here, it is useful and our /bin/sh allows it.
+		echo '$(trap) is broken'
+		exit 1
+	fi
+	trap - USR1
+	eval "$traps"
+	traps2=$(trap)
+	if [ "$traps" != "$traps2" ]; then
+		echo "Mismatch for '$teststring'"
+		exit 1
+	fi
+}
+
+runtest 'echo'
+runtest 'echo hi'
+runtest "'echo' 'hi'"
+runtest '"echo" $PATH'
+runtest '\echo "$PATH"'
+runtest ' 0'
+runtest '0 '
+runtest ' 1'
+runtest '1 '
+i=1
+while [ $i -le 127 ]; do
+	c=$(printf \\"$(printf %o $i)")
+	if [ $i -lt 48 ] || [ $i -gt 57 ]; then
+		runtest "$c"
+	fi
+	runtest " $c$c"
+	runtest "a$c"
+	i=$((i+1))
+done
+IFS=,
+runtest ' '
+runtest ','
+unset IFS
+runtest ' '
+
+exit 0

Added: head/tools/regression/bin/sh/errors/backquote-error1.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/errors/backquote-error1.0	Fri Jun 19 22:15:59 2009	(r194517)
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+echo 'echo `for` echo ".BAD"CODE.' | sh -i 2>&1 | grep -q BADCODE && exit 1
+exit 0



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906192215.n5JMFxtt056887>