Re: Fwd: read builtin return non-zero status reason
Cuong Manh Le wrote: > I'm sorry for that. It's not the time between post but after sending the > email, I look at the help-bash archive and see it have no active email > since January. There has been lots and lots of email in the archive since January. http://lists.gnu.org/archive/html/help-bash/2016-02/threads.html Maybe the archive you were looking at is dead? Note that the gnu.org archive only updates every half hour. Therefore messages don't show up there immediately even when they have been sent to the list immediately. > Anyway, still my fault. Don't worry about it. It is all in the past now. Bob
Re: Fwd: read builtin return non-zero status reason
Hi Bob, I'm sorry for that. It's not the time between post but after sending the email, I look at the help-bash archive and see it have no active email since January. Anyway, still my fault. Thanks. On Wed, Feb 24, 2016 at 11:58 PM, Bob Proulx wrote: > Greg Wooledge wrote: > > On Wed, Feb 24, 2016 at 11:31:40AM +0700, Cuong Manh Le wrote: > > > I send this email to help-bash but it seems to be inactive. Please > help me > > > with this problem. Thanks. > > > > help-bash is active. You probably just didn't wait long enough. > > If this is your first message to help-bash, your message is probably > > waiting in some moderation/antispam queue. > > Impatience is the problem. Here are the times of the three messages. > > help-bash: Date: Wed, 24 Feb 2016 11:14:31 +0700 > help-bash: Date: Wed, 24 Feb 2016 11:20:46 +0700 >bug-bash: Date: Wed, 24 Feb 2016 11:31:40 +0700 > > You waited six minutes for a response to help-bash and then sent it > there again. You then waited eleven minutes before forwarding it to > bug-bash. Neither six nor eleven minutes is a reasonable amount of > time to wait for a response. > > Plus your timezone is +0700 while most of the moderation folks and > bash folks operate out of -0500 through -0800. It may be the middle > of the day for you but that is the middle of the night for others. > Your first message was held for moderation and released at a very > early morning time of 05:44:56 -0800. Your bug-bash message had no > moderation delay probably due to previous contact there. > > Please have some patience. > > Bob >
Re: Fwd: read builtin return non-zero status reason
Greg Wooledge wrote: > On Wed, Feb 24, 2016 at 11:31:40AM +0700, Cuong Manh Le wrote: > > I send this email to help-bash but it seems to be inactive. Please help me > > with this problem. Thanks. > > help-bash is active. You probably just didn't wait long enough. > If this is your first message to help-bash, your message is probably > waiting in some moderation/antispam queue. Impatience is the problem. Here are the times of the three messages. help-bash: Date: Wed, 24 Feb 2016 11:14:31 +0700 help-bash: Date: Wed, 24 Feb 2016 11:20:46 +0700 bug-bash: Date: Wed, 24 Feb 2016 11:31:40 +0700 You waited six minutes for a response to help-bash and then sent it there again. You then waited eleven minutes before forwarding it to bug-bash. Neither six nor eleven minutes is a reasonable amount of time to wait for a response. Plus your timezone is +0700 while most of the moderation folks and bash folks operate out of -0500 through -0800. It may be the middle of the day for you but that is the middle of the night for others. Your first message was held for moderation and released at a very early morning time of 05:44:56 -0800. Your bug-bash message had no moderation delay probably due to previous contact there. Please have some patience. Bob
Re: Fwd: read builtin return non-zero status reason
On Wed, Feb 24, 2016 at 09:45:02PM +0700, Cuong Manh Le wrote: > If you put it into a while loop context: > > while read -d '' line; do echo "$line"; done < <(printf '1') > > > give you nothing. There's only one read in this case > > There's data to read, but read return non-zero there. it doesn't find > delimiter, does it? It encounters EOF before it reads the delimiter. So, you can say "it returned nonzero because it encountered EOF", or "it returned nonzero because it didn't read the delimiter", or "it returned nonzero because the delimiter is missing". They all mean the same thing. P.S. in this case, the value 1 is in the variable line, even though read returned nonzero. You *do* get the partial line. > Compare to: > > while read -d '' line; do echo "$line"; done < <(printf '1\0') > > > give you 1. There two read, the first *read* 1, the second reached EOF, > cause the while loop terminated. The while loop terminates *because* read returns nonzero, not the other way around. Otherwise, that's correct.
Re: Fwd: read builtin return non-zero status reason
Why there's no different? EOF means you have nothing to read. If you put it into a while loop context: while read -d '' line; do echo "$line"; done < <(printf '1') give you nothing. There's only one read in this case There's data to read, but read return non-zero there. it doesn't find delimiter, does it? Compare to: while read -d '' line; do echo "$line"; done < <(printf '1\0') give you 1. There two read, the first *read* 1, the second reached EOF, cause the while loop terminated. On Wed, Feb 24, 2016 at 9:24 PM, Greg Wooledge wrote: > > > It's the same thing. "Reached EOF before seeing the delimiter" is the > > > whole, combined reason. > > > > How can we verify it? > > > > Stephane Chazelas also have the same opinion with me in his answer > > http://unix.stackexchange.com/a/265484/38906, that's error came from no > > delimiter found. > > You're confused. There is no difference between the two things. They > are the two sides of the same check. > > When read reads from stdin, it will either encounter EOF, or it won't. > If it encounters EOF, it returns nonzero. If it doesn't encounter EOF, > it looks to see if it found the delimiter character. If so, it returns > zero. If not, it continues reading. > > That's literally all of the possible outcomes, apart from non-EOF errors. >
Re: Fwd: read builtin return non-zero status reason
> > It's the same thing. "Reached EOF before seeing the delimiter" is the > > whole, combined reason. > > How can we verify it? > > Stephane Chazelas also have the same opinion with me in his answer > http://unix.stackexchange.com/a/265484/38906, that's error came from no > delimiter found. You're confused. There is no difference between the two things. They are the two sides of the same check. When read reads from stdin, it will either encounter EOF, or it won't. If it encounters EOF, it returns nonzero. If it doesn't encounter EOF, it looks to see if it found the delimiter character. If so, it returns zero. If not, it continues reading. That's literally all of the possible outcomes, apart from non-EOF errors.
Re: Fwd: read builtin return non-zero status reason
> > It's the same thing. "Reached EOF before seeing the delimiter" is the > whole, combined reason. How can we verify it? Stephane Chazelas also have the same opinion with me in his answer http://unix.stackexchange.com/a/265484/38906, that's error came from no delimiter found. IMHO, it will be better if bash can return different status code for two cases. Thanks. On Wed, Feb 24, 2016 at 8:37 PM, Greg Wooledge wrote: > On Wed, Feb 24, 2016 at 11:31:40AM +0700, Cuong Manh Le wrote: > > I send this email to help-bash but it seems to be inactive. Please help > me > > with this problem. Thanks. > > help-bash is active. You probably just didn't wait long enough. > If this is your first message to help-bash, your message is probably > waiting in some moderation/antispam queue. > > > The bash read builtin documentation said that when read reached EOF, it's > > return non-zero status. So in: > > > > read -d '' l <<- EOF > > test > > EOF > > > > > > Did read return non-zero status because of it reached EOF or it failed to > > read the whole input because it could not find the delimiter? > > It's the same thing. "Reached EOF before seeing the delimiter" is the > whole, combined reason. >
Re: Fwd: read builtin return non-zero status reason
On Wed, Feb 24, 2016 at 11:31:40AM +0700, Cuong Manh Le wrote: > I send this email to help-bash but it seems to be inactive. Please help me > with this problem. Thanks. help-bash is active. You probably just didn't wait long enough. If this is your first message to help-bash, your message is probably waiting in some moderation/antispam queue. > The bash read builtin documentation said that when read reached EOF, it's > return non-zero status. So in: > > read -d '' l <<- EOF > test > EOF > > > Did read return non-zero status because of it reached EOF or it failed to > read the whole input because it could not find the delimiter? It's the same thing. "Reached EOF before seeing the delimiter" is the whole, combined reason.
Fwd: read builtin return non-zero status reason
I send this email to help-bash but it seems to be inactive. Please help me with this problem. Thanks. -- Forwarded message -- From: Cuong Manh Le Date: Wed, Feb 24, 2016 at 11:14 AM Subject: read builtin return non-zero status reason To: help-b...@gnu.org The bash read builtin documentation said that when read reached EOF, it's return non-zero status. So in: read -d '' l <<- EOF test EOF Did read return non-zero status because of it reached EOF or it failed to read the whole input because it could not find the delimiter? IMHO, the second reason is correct. The full story is here: http://unix.stackexchange.com/q/265149/38906. I and the other one have conflict about this. Correct me if I'm wrong. Thanks.