[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), Коренберг Марк:
[...]
> mmarkk@mmarkk-work:/tmp$ echo aaa > /tmp/test1
> mmarkk@mmarkk-work:/tmp$ read x < /tmp/test1 && echo success
> success
> mmarkk@mmarkk-work:/tmp$ echo $x
> aaa
> mmarkk@mmarkk-work:/tmp$
>
> BUGGY CASE:
> mmarkk@mmarkk-work:/tmp$ echo -n bbb > /tmp/test2
> mmarkk@mmarkk-work:/tmp$ read y < /tmp/test2 && echo success
> mmarkk@mmarkk-work:/tmp$ echo $y
> bbb
> mmarkk@mmarkk-work:/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