Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Sep 2010 21:17:33 +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: r212187 - head/tools/regression/bin/sh/builtins
Message-ID:  <201009032117.o83LHXCc063317@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Fri Sep  3 21:17:33 2010
New Revision: 212187
URL: http://svn.freebsd.org/changeset/base/212187

Log:
  sh: Add a test that 'read' leaves the file pointer at the correct place.
  
  Naive buffering would break the common while read x... construct, which did
  not appear to be tested yet.

Added:
  head/tools/regression/bin/sh/builtins/read2.0   (contents, props changed)

Added: head/tools/regression/bin/sh/builtins/read2.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/builtins/read2.0	Fri Sep  3 21:17:33 2010	(r212187)
@@ -0,0 +1,31 @@
+# $FreeBSD$
+
+set -e
+{
+	echo 1
+	echo two
+	echo three
+} | {
+	read x
+	[ "$x" = 1 ]
+	(read x
+	[ "$x" = two ])
+	read x
+	[ "$x" = three ]
+}
+
+T=`mktemp sh-test.XXXXXX`
+trap 'rm -f "$T"' 0
+{
+	echo 1
+	echo two
+	echo three
+} >$T
+{
+	read x
+	[ "$x" = 1 ]
+	(read x
+	[ "$x" = two ])
+	read x
+	[ "$x" = three ]
+} <$T



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