Permalink
Browse files

Fix a test for the read builtin.

It was only failing because of differing echo behavior in 'echo'.  So
instead we use here docs and printf "%s\n".

Also, run busybox ash with quote.test.sh.  ash actually implements more
quoting behavior than dash!  They have diverged significantly.
  • Loading branch information...
Andy Chu
Andy Chu committed Jan 8, 2018
1 parent 3b9a3b9 commit fc0d46355b1fbc4aaef9885bbf701e09ff62249f
Showing with 14 additions and 10 deletions.
  1. +11 −7 spec/builtin-io.test.sh
  2. +1 −1 spec/quote.test.sh
  3. +2 −2 test/spec.sh
View
@@ -230,6 +230,7 @@ argv "$escaped" "$raw"
# BUG mksh/zsh stdout: ['one twoethree', 'one\\ twoethree']
### read with line continuation reads multiple physical lines
# NOTE: osh failing because of file descriptor issue. stdin has to be closed!
tmp=$TMP/$(basename $SH)-readr.txt
echo -e 'one\\\ntwo\n' > $tmp
read escaped < $tmp
@@ -272,14 +273,17 @@ echo "[$var]"
### Read multiple lines with IFS=:
# The leading spaces are stripped if they appear in IFS.
# IFS chars are escaped with :.
tmp=$TMP/$(basename $SH)-read-ifs.txt
IFS=:
{ echo ' \\a :b\: c:d\';
echo ' e'
} > $TMP/read-ifs.txt
read a b c d < $TMP/read-ifs.txt
echo "[$a|$b|$c|$d]"
# stdout: [ a |b: c|d e|]
# BUG bash stdout: [ \a |b: c|d e|]
cat >$tmp <<'EOF'
\\a :b\: c:d\
e
EOF
read a b c d < $tmp
# Use printf because echo in dash/mksh interprets escapes, while it doesn't in
# bash.
printf "%s\n" "[$a|$b|$c|$d]"
# stdout: [ \a |b: c|d e|]
### Read with IFS=''
IFS=''
View
@@ -148,7 +148,7 @@ echo $'col1\ncol2\ncol3'
### $""
echo $"foo"
# stdout: foo
# N-I dash stdout: $foo
# N-I dash/ash stdout: $foo
### printf
# This accepts \t by itself, hm.
View
@@ -237,7 +237,7 @@ subshell() {
# Need to implement $'' escaping
quote() {
sh-spec spec/quote.test.sh --osh-failures-allowed 1 \
${REF_SHELLS[@]} $OSH "$@"
${REF_SHELLS[@]} $BUSYBOX_ASH $OSH "$@"
}
loop() {
@@ -262,7 +262,7 @@ builtins() {
}
builtin-io() {
sh-spec spec/builtin-io.test.sh --osh-failures-allowed 2 \
sh-spec spec/builtin-io.test.sh --osh-failures-allowed 1 \
${REF_SHELLS[@]} $ZSH $OSH "$@"
}

0 comments on commit fc0d463

Please sign in to comment.