From 6114ee2fe31627d9570b458d403f28f0a08aeace Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 25 Apr 2005 10:40:52 +0000 Subject: Fix handling of metafied characters in trailing whitespace on read --- Test/B04read.ztst | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Test/B04read.ztst (limited to 'Test') diff --git a/Test/B04read.ztst b/Test/B04read.ztst new file mode 100644 index 000000000..d6b7ce0b1 --- /dev/null +++ b/Test/B04read.ztst @@ -0,0 +1,78 @@ +# Tests for the read builtin + +# Tested elsewhere: +# reading from a coprocess A01grammar, A04redirect + +# Not tested: +# -c/-l/-n (options for compctl functions) +# -q/-s (needs a tty) + +%test + + read <<<'hello world' + print $REPLY +0:basic read command +>hello world + + read -A <<<'hello world' + print $reply[2] +0:array read +>world + + read -k3 -u0 <<foo + + read -d: <<foo + + print foo:bar|IFS=: read -A + print $reply +0:use different, IFS separator to array +>foo bar + + print -z hello world; read -z + print $REPLY +0:read from editor buffer stack +>hello world + + unset REPLY + read -E <<hello +>hello + + unset REPLY + read -e <<hello +> + + read -e -t <<hello + + SECONDS=0 + read -e -t 5 <<hello +>0 + + print -n 'Testing the\0null hypothesis\0' | + while read -d $'\0' line; do print $line; done +0:read with null delimiter +>Testing the +>null hypothesis + +# Note that trailing NULLs are not stripped even if they are in +# $IFS; only whitespace characters contained in $IFS are stripped. + print -n $'Aaargh, I hate nulls.\0\0\0' | read line + print ${#line} +0:read with trailing metafied characters +>24 -- cgit 1.4.1