[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: |
Mon, 27 Dec 2010 17:59:09 +0000 (UTC) |
User-agent: |
slrn/pre1.0.0-18 (Linux) |
2010-12-27, 09:43(-07), Eric Blake:
[...]
> On 12/26/2010 01:29 PM, Stephane CHAZELAS wrote:
>> Bash behavior is the same as every other shell, is as documented
>> and as specified by POSIX.
>
> POSIX requires that the input to read be a text file. Since you aren't
> passing a text file, the behavior is undefined. POSIX does NOT require
> bash to return failure in this case, but neither does it require bash to
> return success. You should not rely on the behavior of read when the
> input does not end in a newline.
[...]
From
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/read.html
SUSv4> EXIT STATUS
SUSv4>
SUSv4> The following exit values shall be returned:
SUSv4>
SUSv4> 0
SUSv4> Successful completion.
SUSv4> >0
SUSv4> End-of-file was detected or an error occurred.
SUSv4>
So I think you can expect a non-zero status here.
--
Stephane