summaryrefslogtreecommitdiffstats
path: root/tools/regression
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-09-03 21:17:33 +0000
committerjilles <jilles@FreeBSD.org>2010-09-03 21:17:33 +0000
commit8d1940fec48b6da2d4b26c4da4d97917c9490196 (patch)
tree11e81669d1eb3d7ec73741c01378b013459bdf70 /tools/regression
parentda8f4a1650c2d6e42ae9918c0225e7274e7a1789 (diff)
downloadFreeBSD-src-8d1940fec48b6da2d4b26c4da4d97917c9490196.zip
FreeBSD-src-8d1940fec48b6da2d4b26c4da4d97917c9490196.tar.gz
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.
Diffstat (limited to 'tools/regression')
-rw-r--r--tools/regression/bin/sh/builtins/read2.031
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/builtins/read2.0 b/tools/regression/bin/sh/builtins/read2.0
new file mode 100644
index 0000000..fc74511
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/read2.0
@@ -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
OpenPOWER on IntegriCloud