changes to mapfile, read builtins for unbuffered reads

This commit is contained in:
Chet Ramey
2021-05-05 10:45:28 -04:00
parent b196583609
commit 59c575fd91
10 changed files with 72 additions and 11 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/chet/bash/bash-current
BUILD_DIR=/usr/local/build/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
+6
View File
@@ -30,6 +30,7 @@ argv[1] = <foo>
argv[1] = <foo>
argv[1] = < foo>
a = abcdefg
xyz
a = xyz
a = -xyz 123-
a = abc
@@ -46,6 +47,7 @@ abcde
abcde
./read3.sub: line 17: read: -1: invalid number
abc
defg
ab
abc
#
@@ -76,3 +78,7 @@ unset or null 3
[?2004h[?2004l
timeout 3: ok
unset or null 3
timeout 4: ok
abcde
abcde
one
+3
View File
@@ -112,3 +112,6 @@ ${THIS_SH} ./read6.sub
# test behavior of readline timeouts
${THIS_SH} ./read7.sub
# test behavior of read -n and read -d on regular files
${THIS_SH} ./read8.sub
+1
View File
@@ -15,6 +15,7 @@ a=7
echo 'abcdefg|xyz' | {
read -d '|' a
echo a = "${a-unset}"
cat - # make sure we don't read too much
}
echo xyz 123 | {
+1
View File
@@ -20,6 +20,7 @@ read -n -1
echo abcdefg | {
read -n 3 xyz
echo $xyz
cat - # make sure we don't read too much
}
# fewer chars than specified
+15
View File
@@ -0,0 +1,15 @@
tmpf=$TMPDIR/tmp-$$
printf "%s\n" "one two three four" > $tmpf
# make sure we rewind the input properly when reading a specific number of
# characters or using a non-standard delimiter from a regular file
exec <$tmpf
read -n 4 input && echo "$input"
cat -
exec <$tmpf
read -d ' ' input && echo "$input"
cat -
rm -f $tmpf