bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: read builtin does not return success code (0) in spite of it success


From: Stephane CHAZELAS
Subject: Re: read builtin does not return success code (0) in spite of it successfully read line
Date: Sun, 26 Dec 2010 20:29:30 +0000 (UTC)
User-agent: slrn/pre1.0.0-18 (Linux)

2010-12-24, 13:20(+05), Коренберг Марк:
[...]
> address@hidden:/tmp$ echo aaa > /tmp/test1
> address@hidden:/tmp$ read x < /tmp/test1 && echo success
> success
> address@hidden:/tmp$ echo $x
> aaa
> address@hidden:/tmp$
>
> BUGGY CASE:
> address@hidden:/tmp$ echo -n bbb > /tmp/test2
> address@hidden:/tmp$ read y < /tmp/test2 && echo success
> address@hidden:/tmp$ echo $y
> bbb
> address@hidden:/tmp$
>
> So, if EOF detected but something is read successfully, please do not 
> report error !
[...]

Bash behavior is the same as every other shell, is as documented
and as specified by POSIX.

if read can't read a line (because of a read error or EOF
found before the line terminator is found) it should return a
non-zero exit status and fill the variable with the caracters
read thus far.

-- 
Stephane


reply via email to

[Prev in Thread] Current Thread [Next in Thread]