[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
Re: read builtin does not return success code (0) in spite of it successfully read line
Mon, 27 Dec 2010 21:11:20 +0000 (UTC)
2010-12-27, 11:53(-07), Eric Blake:
>> So I think you can expect a non-zero status here.
> All you can expect is that you have undefined results. Undefined
> results include zero status.
Yes, sorry, you're right. Bad reasoning of mine. The >0 on EOF
is oviously on end of text file, that is when there's nothing
left to be read after the last newline character. On a terminal,
you'd express that EOF by entering the eof character on an empty
Having said that, all the implementations are returning a
non-zero exit status on an unfinished line and it also sounds to
me like the best option (as it allows to diffentiate a
terminated line from an unfinished one and can also be seen as
an error condition), so it would be unwise IMO for bash to
change its behavior to return 0 in this case.