diff options
author | stefanf <stefanf@FreeBSD.org> | 2009-03-22 22:14:46 +0000 |
---|---|---|
committer | stefanf <stefanf@FreeBSD.org> | 2009-03-22 22:14:46 +0000 |
commit | 79a3bf3a75f72903a310ed9bb412bf42cd9f7f53 (patch) | |
tree | b8df659dc931f2d927129d3e3cb5599e4c12ac7c /tools/regression | |
parent | 7836b44d7b128643e39e8059d8a0d9fb69bae222 (diff) | |
download | FreeBSD-src-79a3bf3a75f72903a310ed9bb412bf42cd9f7f53.zip FreeBSD-src-79a3bf3a75f72903a310ed9bb412bf42cd9f7f53.tar.gz |
Add a few tests for the read built-in.
Diffstat (limited to 'tools/regression')
-rw-r--r-- | tools/regression/bin/sh/builtins/read1.0 | 25 | ||||
-rw-r--r-- | tools/regression/bin/sh/builtins/read1.0.stdout | 19 |
2 files changed, 44 insertions, 0 deletions
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 |