Re: read command sometimes misses newline on timeout

2024-10-07 Thread alex xmb sw ratchev
well try remove the -n in echo On Monday, October 7, 2024, Thomas Oettli wrote: > Sorry Alex, I don't understand exactly what you mean. > Here is the Test-Script again with some comments: > > function reader() { > local buf line > while :; do > read -t .01 buf

AW: Re: read command sometimes misses newline on timeout

2024-10-07 Thread Thomas Oettli via Bug reports for the GNU Bourne Again SHell
I agree with you, but it should never happen that read returns timeout, also returns the full line and has already read the newline character. If that happens, there is no way for the script to decide what to do. Please see the provided test script, it showcases the error. If I did a mistake the

Re: read command sometimes misses newline on timeout

2024-10-07 Thread alex xmb sw ratchev
there is a case , u [[ $readreply ]] after read On Monday, October 7, 2024, Thomas Oettli via Bug reports for the GNU Bourne Again SHell wrote: > I agree with you, but it should never happen that read returns timeout, > also returns the full line and has already read the newline character. > If

AW: Re: read command sometimes misses newline on timeout

2024-10-07 Thread Thomas Oettli via Bug reports for the GNU Bourne Again SHell
I know that it works in that case. This is just an example that tries to force read into the same situatiation that I hit in a real world example in which I don't control the input. Von: alex xmb sw ratchev Gesendet: Montag, 7. Oktober 2024 19:17 An: Thomas Oett

AW: Re: read command sometimes misses newline on timeout

2024-10-07 Thread Thomas Oettli via Bug reports for the GNU Bourne Again SHell
I guess I will wait for an answer from Martin D Kealey. His answer tells me that he understood what issue I have. But thank you a lot, nevertheless. BTW: I have already tried all kinds of combinations including read -t 0 and could not find a working solution, that is why I filled a bug report. __

Re: read command sometimes misses newline on timeout

2024-10-07 Thread Chet Ramey
On 10/4/24 8:18 AM, Thomas Oettli via Bug reports for the GNU Bourne Again SHell wrote: Bash Version: 5.2 Patch Level: 26 Release Status: release Description: I have tried to write a bash script that asynchronously reads from a pipe (line by line) with the help of "read -t". If t

Re: Bash debugging.

2024-10-07 Thread Chet Ramey
On 10/5/24 4:14 PM, David Shuman wrote: I have been working on several items as I am using bash to configure systems. I started wanting to log the output of my scripts. Then I added a prefixed message construct so detailed logs could be summarized without extraneous debugging information (I hav

Re: ${param@a} should bypass unbound variable check or be processed ahead of it.

2024-10-07 Thread konsolebox
Changing "c == '@'" to "c == '@' && !want_attributes" in line 10145 of subst.c seems enough to fix it. -- konsolebox diff --git a/subst.c b/subst.c index 251eafaf..9ee816e0 100644 --- a/subst.c +++ b/subst.c @@ -10142,7 +10142,7 @@ parameter_brace_expand (char *string, size_t *indexp, int quoted

AW: Re: read command sometimes misses newline on timeout

2024-10-07 Thread Thomas Oettli via Bug reports for the GNU Bourne Again SHell
Sorry Alex, I don't understand exactly what you mean. Here is the Test-Script again with some comments: function reader() { local buf line while :; do read -t .01 buf # try to read line to $buf with timeout rc=$? if (( rc == 0 )); then

Re: read command sometimes misses newline on timeout

2024-10-07 Thread alex xmb sw ratchev
to know if read returned anything , even if its exit code is not 0 , check using [[ $reply ]] i really didnt get ur english or issue On Monday, October 7, 2024, Thomas Oettli wrote: > > I know that it works in that case. > This is just an example that tries to force read into the same > situati

Re: Fwd: read command sometimes misses newline on timeout

2024-10-07 Thread Greg Wooledge
> -- Forwarded message -- > From: *Thomas Oettli* >1. the script calls "read" on pipe >2. "read" hits timeout just after it has read "\n" from the pipe >3. "read" returns the full line, but exits with rc > 128 >4. the script assumes a partial line, appends received

Re: read command sometimes misses newline on timeout

2024-10-07 Thread Martin D Kealey
OK, running a similar test with instrumentation gets: $ time ( trap ' echo BANG ' SIGALRM ; while :; do printf TEST; sleep .00$((1+RANDOM%2)); echo; done | for ((r=10 ;r>0; --r)) do line= ; read -t .002 line; rc=$?; [[ $line = TEST ]] ; echo "STATUS $rc $? $line" ; done ) |& sort | un

Re: Fwd: read command sometimes misses newline on timeout

2024-10-07 Thread Martin D Kealey
On Tue, 8 Oct 2024 at 06:26, Greg Wooledge wrote: > From: *Thomas Oettli* > > The result is two lines in the buffer (without "\n" in between). Do you > understand now what I mean? > > If bash is returning nonzero status after reading a full line, then that > may be a bug that should be fixed. >