diff options
author | jilles <jilles@FreeBSD.org> | 2010-09-03 21:17:33 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-09-03 21:17:33 +0000 |
commit | 8d1940fec48b6da2d4b26c4da4d97917c9490196 (patch) | |
tree | 11e81669d1eb3d7ec73741c01378b013459bdf70 /tools | |
parent | da8f4a1650c2d6e42ae9918c0225e7274e7a1789 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | tools/regression/bin/sh/builtins/read2.0 | 31 |
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 |