Fix incorrect error on read with 1-character input

When `read` is given a single character of input (including the
newline), it was bailing as if it had been given no input. This is
incorrect.
This commit is contained in:
Kevin Ballard 2014-09-21 20:00:26 -07:00
parent a9c8b75599
commit a012aedb31
3 changed files with 4 additions and 1 deletions

View file

@ -2655,7 +2655,7 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
}
}
if (buff.size() < 2 && eof)
if (buff.empty() && eof)
{
exit_res = 1;
}

View file

@ -38,6 +38,8 @@ echo 'test' | read -l one two three
print_vars one two three
echo 'foo bar baz' | read -l one two three
print_vars one two three
echo -n 'a' | read -l one
echo "$status $one"
echo
set -l IFS

View file

@ -17,6 +17,7 @@ two
1 '' 1 ''
1 'test' 1 '' 1 ''
1 'foo' 1 'bar' 1 ' baz'
0 a
1 'hello'
1 'h' 1 'ello'