From 79a3bf3a75f72903a310ed9bb412bf42cd9f7f53 Mon Sep 17 00:00:00 2001 From: stefanf Date: Sun, 22 Mar 2009 22:14:46 +0000 Subject: Add a few tests for the read built-in. --- tools/regression/bin/sh/builtins/read1.0 | 25 +++++++++++++++++++++++++ tools/regression/bin/sh/builtins/read1.0.stdout | 19 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tools/regression/bin/sh/builtins/read1.0 create mode 100644 tools/regression/bin/sh/builtins/read1.0.stdout diff --git a/tools/regression/bin/sh/builtins/read1.0 b/tools/regression/bin/sh/builtins/read1.0 new file mode 100644 index 0000000..1bca518 --- /dev/null +++ b/tools/regression/bin/sh/builtins/read1.0 @@ -0,0 +1,25 @@ +# $FreeBSD$ +set -e + +echo "1 2 3" | { read a; echo "x${a}x"; } +echo "1 2 3" | { read a b; echo "x${a}x${b}x"; } +echo "1 2 3" | { read a b c; echo "x${a}x${b}x${c}x"; } +echo "1 2 3" | { read a b c d; echo "x${a}x${b}x${c}x${d}x"; } + +echo " 1 2 3 " | { read a b c; echo "x${a}x${b}x${c}x"; } +echo " 1 2 3 " | { IFS=$(printf ' \t\n') read a b c; echo "x${a}x${b}x${c}x"; } +echo " 1 2 3 " | { IFS= read a b; echo "x${a}x${b}x"; } + +echo " 1,2 3 " | { IFS=' ,' read a b c; echo "x${a}x${b}x${c}x"; } +echo ", 2 ,3" | { IFS=' ,' read a b c; echo "x${a}x${b}x${c}x"; } +echo " 1 ,,3" | { IFS=' ,' read a b c; echo "x${a}x${b}x${c}x"; } +echo " 1 , , 3" | { IFS=' ,' read a b c; echo "x${a}x${b}x${c}x"; } +echo " 1 ,2 3," | { IFS=' ,' read a b c; echo "x${a}x${b}x${c}x"; } +echo " 1 ,2 3,," | { IFS=' ,' read a b c; echo "x${a}x${b}x${c}x"; } + +echo " 1,2 3 " | { IFS=', ' read a b c; echo "x${a}x${b}x${c}x"; } +echo ", 2 ,3" | { IFS=', ' read a b c; echo "x${a}x${b}x${c}x"; } +echo " 1 ,,3" | { IFS=', ' read a b c; echo "x${a}x${b}x${c}x"; } +echo " 1 , , 3" | { IFS=', ' read a b c; echo "x${a}x${b}x${c}x"; } +echo " 1 ,2 3," | { IFS=', ' read a b c; echo "x${a}x${b}x${c}x"; } +echo " 1 ,2 3,," | { IFS=', ' read a b c; echo "x${a}x${b}x${c}x"; } diff --git a/tools/regression/bin/sh/builtins/read1.0.stdout b/tools/regression/bin/sh/builtins/read1.0.stdout new file mode 100644 index 0000000..752b969 --- /dev/null +++ b/tools/regression/bin/sh/builtins/read1.0.stdout @@ -0,0 +1,19 @@ +x1 2 3x +x1x2 3x +x1x2x3x +x1x2x3xx +x1x2x3x +x1x2x3x +x 1 2 3 xx +x1x2x3x +xx2x3x +x1xx3x +x1xx3x +x1x2x3x +x1x2x3,,x +x1x2x3x +xx2x3x +x1xx3x +x1xx3x +x1x2x3x +x1x2x3,,x -- cgit v1.1