AW: Re: AW: Re: AW: Re: AW: Re: read command sometimes misses newline on timeout

2024-11-07 Thread Thomas Oettli
I can confirm that the patch resolves all the issues I had. Thank you very much for your help, it is very appreciated. On 10/15/24 11:08 AM, Thomas Oettli wrote: > Got it, I just backported your patch to Bash 5.2 and it fixed the issue on > my build host. > I will roll out the patched version to a

Re: AW: Re: AW: Re: AW: Re: read command sometimes misses newline on timeout

2024-10-15 Thread Chet Ramey
On 10/15/24 11:08 AM, Thomas Oettli wrote: Got it, I just backported your patch to Bash 5.2 and it fixed the issue on my build host. I will roll out the patched version to all my hosts this weekend and keep you noticed if anything strange happens. BTW: will this patch be backported to previous

AW: Re: AW: Re: AW: Re: read command sometimes misses newline on timeout

2024-10-15 Thread Thomas Oettli via Bug reports for the GNU Bourne Again SHell
? Von: Chet Ramey Gesendet: Dienstag, 15. Oktober 2024 16:24 An: Thomas Oettli ; bug-bash@gnu.org Cc: chet.ra...@case.edu Betreff: [EXT] Re: AW: Re: AW: Re: read command sometimes misses newline on timeout CAUTION: This email originated from outside the SFS organization. Do not follow

Re: AW: Re: AW: Re: read command sometimes misses newline on timeout

2024-10-15 Thread Chet Ramey
On 10/15/24 10:06 AM, Thomas Oettli wrote: That sounds promising. Is the fix somewhere accessible for me? I would gladly test it. I pushed it to the devel branch this morning. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocra

AW: Re: AW: Re: read command sometimes misses newline on timeout

2024-10-15 Thread Thomas Oettli
That sounds promising. Is the fix somewhere accessible for me? I would gladly test it. - Thomas

Re: AW: Re: read command sometimes misses newline on timeout

2024-10-12 Thread Chet Ramey
On 10/7/24 9:49 AM, Thomas Oettli 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 that happens, there is no way for the script to decide what to do. I think I found the problem and fixed

Re: AW: Re: read command sometimes misses newline on timeout

2024-10-12 Thread Chet Ramey
On 10/7/24 9:49 AM, Thomas Oettli 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. I don't see how that can happen, given how the code is structured. It's possible for the shell to re

AW: Re: read command sometimes misses newline on timeout

2024-10-08 Thread Thomas Oettli via Bug reports for the GNU Bourne Again SHell
your help. * Thomas Von: Martin D Kealey Gesendet: Dienstag, 8. Oktober 2024 06:23 An: Martin D Kealey Cc: Thomas Oettli ; bug-bash Betreff: [EXT] Re: read command sometimes misses newline on timeout CAUTION: This email originated from outside the SFS

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. >

Re: read command sometimes misses newline on timeout

2024-10-07 Thread Martin D Kealey
ot; ; done ) |& sort | uniq -c 1 +# Hit read timeout SIGALRM, run from line 699 in ./read.def #+ STATUS 142 1 TES 1 +# Hit read timeout SIGALRM, run from line 72 in zread.c #+ STATUS 142 1 2 +# Hit read timeout SIGALRM, run from line 865 in ./read.def #+ STATUS 142 1 T 1

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 &

AW: Re: read command sometimes misses newline on timeout

2024-10-07 Thread Thomas Oettli via Bug reports for the GNU Bourne Again SHell
. Von: alex xmb sw ratchev Gesendet: Montag, 7. Oktober 2024 21:50 An: Thomas Oettli ; bash list Betreff: [EXT] Re: read command sometimes misses newline on timeout CAUTION: This email originated from outside the SFS organization. Do not follow guidance, click links

Re: read command sometimes misses newline on timeout

2024-10-07 Thread alex xmb sw ratchev
t; chet.ra...@case.edu> > *Betreff:* [EXT] Re: read command sometimes misses newline on timeout > > CAUTION: This email originated from outside the SFS organization. Do not > follow guidance, click links or open attachments unless you recognize the > sender and know the content

AW: Re: read command sometimes misses newline on timeout

2024-10-07 Thread Thomas Oettli via Bug reports for the GNU Bourne Again SHell
homas Oettli Cc: bug-bash@gnu.org ; chet.ra...@case.edu Betreff: [EXT] Re: read command sometimes misses newline on timeout CAUTION: This email originated from outside the SFS organization. Do not follow guidance, click links or open attachments unless you recognize the sender and know the conte

Re: read command sometimes misses newline on timeout

2024-10-07 Thread alex xmb sw ratchev
t; read -t .01 buf # try to read line to $buf with > timeout > rc=$? > if (( rc == 0 )); then # got a full line or the rest of a > partial line, append $buf to $line > line+=$buf > elif (( rc > 128 )); then

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 ));

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

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

Re: read command sometimes misses newline on timeout

2024-10-07 Thread Chet Ramey
;. If the timeout occurs in just the right moment, read returns the full line, but the return code says timeout (rc > 128). If the read command times out, it always returns > 128, so if you have a return code in that range, you can assume read timed out and react accordingly. Th

Re: read command sometimes misses newline on timeout

2024-10-05 Thread Martin D Kealey
GenuineIntel > GNU/Linux > Machine Type: x86_64-pc-linux-gnu > > 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 -

read command sometimes misses newline on timeout

2024-10-04 Thread Thomas Oettli via Bug reports for the GNU Bourne Again SHell
GenuineIntel GNU/Linux Machine Type: x86_64-pc-linux-gnu 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 the timeout occurs in just

Re: How difficult would it be to add a timeout to "wait"?

2023-04-21 Thread Chet Ramey
oint is that if it's easy enough -- and it is -- to do it without adding features to bash itself, then there's not a compelling argument, nor sufficient demand, to add more code to bash. So then fleshing this out, let me ask: Is it reasonable to add an optional timeout to the "

Re: How difficult would it be to add a timeout to "wait"?

2023-04-21 Thread Dale R. Worley
Chet Ramey writes: > On 4/20/23 1:53 PM, Dale R. Worley wrote: >> How difficult would it be to add an optional timeout argument to the >> "wait" builtin? > > Try a variant of this. > ... My interest here isn't "Can I accomplish this task with B

Re: How difficult would it be to add a timeout to "wait"?

2023-04-20 Thread Chet Ramey
On 4/20/23 1:53 PM, Dale R. Worley wrote: How difficult would it be to add an optional timeout argument to the "wait" builtin? Try a variant of this. trap 'echo timeout!' USR1 # choose your fighter wait_with_timeout() { pid=$1 timeout=$2 { sl

How difficult would it be to add a timeout to "wait"?

2023-04-20 Thread Dale R. Worley
How difficult would it be to add an optional timeout argument to the "wait" builtin? I occasionally run into situations where this functionality is desirable, more often than I expect, really. And though the last thing Bash needs is an additional feature, naively it seems like it would

Re: $SECONDS and timeout values use realtime `gettimeofday()`

2023-03-29 Thread Mike Jonkmans
to > > use the monotonic timer, adding a new variable like MONOSECONDS, or some > > other call to get monotonic time via clock_gettime). > > Interesting. I was wondering how you got onto this, so I looked around for > any utilities (e.g., timeout, sleep), library functions, or

Re: $SECONDS and timeout values use realtime `gettimeofday()`

2023-03-29 Thread Andreas Schwab
ipts that are sitting in > loops, calculating a timeout based on the $SECONDS variable. The current > behavior using realtime instead of monotime is surprising to us. > > It would be nice if $SECONDS was using `clock_gettime(CLOCK_MONOTONIC, > &val)` as it would usually make the most

Re: $SECONDS and timeout values use realtime `gettimeofday()`

2023-03-29 Thread Chet Ramey
e via clock_gettime). Interesting. I was wondering how you got onto this, so I looked around for any utilities (e.g., timeout, sleep), library functions, or system calls that use the monotonic clock and couldn't find any. It must be too `new'; everyone seems to use the realtime clock. I'll

Re: $SECONDS and timeout values use realtime `gettimeofday()`

2023-03-25 Thread Martin D Kealey
On Fri, 24 Mar 2023 at 10:42, William Kennington via Bug reports for the GNU Bourne Again SHell wrote: > It would be nice if $SECONDS was using `clock_gettime(CLOCK_MONOTONIC, > &val)` as it would usually make the most sense when you want to know the > time since the script started. Generally n

Re: $SECONDS and timeout values use realtime `gettimeofday()`

2023-03-24 Thread William Kennington via Bug reports for the GNU Bourne Again SHell
as the potential to break any scripts that are sitting in > > loops, calculating a timeout based on the $SECONDS variable. The current > > behavior using realtime instead of monotime is surprising to us. > > So the system jumps forward in time at some random point, after the s

Re: $SECONDS and timeout values use realtime `gettimeofday()`

2023-03-24 Thread Chet Ramey
sitting in loops, calculating a timeout based on the $SECONDS variable. The current behavior using realtime instead of monotime is surprising to us. So the system jumps forward in time at some random point, after the shell script has started and $SECONDS has been initialized. You're worried

$SECONDS and timeout values use realtime `gettimeofday()`

2023-03-23 Thread William Kennington via Bug reports for the GNU Bourne Again SHell
We have systems that start off with inaccurate clocks and at some point after the boot process synchronize with the network and jump forward in time. This has the potential to break any scripts that are sitting in loops, calculating a timeout based on the $SECONDS variable. The current behavior

Re: read builtin: timeout setting valid is next read

2022-11-23 Thread Chet Ramey
On 11/23/22 7:52 AM, Csaba wrote: Hello! If I use timeout with read shell command, next read command use it too. Thanks for the report. https://lists.gnu.org/archive/html/bug-bash/2022-11/msg00035.html -- ``The lyf so short, the craft so long to lerne.'' - Chaucer

read builtin: timeout setting valid is next read

2022-11-23 Thread Csaba
Hello! If I use timeout with read shell command, next read command use it too. See my test shell program: #!/bin/bash read -rest 2 od -An -tx1 <<<"${REPLY}" read -ren2 -p $'---\nIs this OK? [y/N] ' echo od -An -tx1 <<<"$

Re: read with very small timeout sometime hand on stdin

2020-11-01 Thread felix
hat was not mine... Tested at https://www.jdoodle.com/ia/3EO $ sed <<"eotest" >/tmp/test-timeout-race.sh 's/^//' #!/bin/bash declare -p BASH_VERSI{NFO,ON} uptime uname -a po() { for f in {1..1};do read -t .

Re: read with very small timeout sometime hand on stdin

2020-10-29 Thread felix
On Wed, Oct 28, 2020 at 09:23:09AM -0400, Chet Ramey wrote: > > I can't reproduce this using the following stripped-down reproducer: > trap 'echo $f ; exit' SIGINT > > for f in {1..1}; do > read -t .01 v > if [ $? -ne 142 ]; then > echo $f: $? > fi > done

Re: read with very small timeout sometime hand on stdin

2020-10-28 Thread Chet Ramey
On 10/28/20 7:06 AM, felix wrote: > Bash Version: 5.1 > Patch Level: 0 > Release Status: rc1 > > Description: > Trying to see limits of timeout with `read -t`, I encounter strange > and unconstant result: sometime `read -t .01` don't consider >

read with very small timeout sometime hand on stdin

2020-10-28 Thread felix
: 0 Release Status: rc1 Description: Trying to see limits of timeout with `read -t`, I encounter strange and unconstant result: sometime `read -t .01` don't consider timeout, when running fastly multiple time. From help: -t timeout time out and return failure... may

Re: ``read -N n -t timeout'' saves partial input only when EOF is seen?

2016-11-28 Thread Chet Ramey
On 11/27/16 3:47 PM, Dmitry Goncharov wrote: > On Fri, Nov 25, 2016 at 12:40:58PM -0500, Chet Ramey wrote: >> On 11/25/16 9:57 AM, Dmitry Goncharov wrote: >>> Auto variables have unspecified values after a call to longjmp. >> >> This is true. It's what the USE_VAR macro is intended to defeat, but

Re: ``read -N n -t timeout'' saves partial input only when EOF is seen?

2016-11-25 Thread Chet Ramey
On 11/25/16 9:57 AM, Dmitry Goncharov wrote: > Auto variables have unspecified values after a call to longjmp. This is true. It's what the USE_VAR macro is intended to defeat, but let's see what marking i volatile does. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer

Re: ``read -N n -t timeout'' saves partial input only when EOF is seen?

2016-11-25 Thread Dmitry Goncharov
that's not true https://gist.github.com/fa4efd90376ff2714901e4429fdee734 >>> read successfully reads the data, but then it's discarded by bash >>> >>> >> >>It's discarded by bash because the read doesn't read 10 >> characters within the

Re: ``read -N n -t timeout'' saves partial input only when EOF is seen?

2016-11-24 Thread Clark Wang
;It's discarded by bash because the read doesn't read 10 > characters within the time limit. If you use -N 5, you get > your output. "-t" says it will timeout and return failure if a > specified number of characters is not read within timeout period. > Th

Re: ``read -N n -t timeout'' saves partial input only when EOF is seen?

2016-11-24 Thread L A Walsh
ou use -N 5, you get your output. "-t" says it will timeout and return failure if a specified number of characters is not read within timeout period. If timeout is exceeded, then return status is > 128: bash -c '( printf 12345; sleep 2 ) | ( read -t 1 -N 10 v; echo "s=$?, <$v>" )' s=142, <> (status is > 128)

Re: ``read -N n -t timeout'' saves partial input only when EOF is seen?

2016-11-24 Thread isabella parakiss
On 11/24/16, Chet Ramey wrote: > On 11/24/16 2:57 AM, Clark Wang wrote: >> See following example: >> >> # echo $BASH_VERSION >> 4.4.5(2)-release >> # ( printf 12345 ) | ( read -t 1 -N 10 v; echo "<$v>" ) >> <12345> >> # ( printf 12345; sleep 2 ) | ( read -t 1 -N 10 v; echo "<$v>" ) >> <> >> # >> >

Re: ``read -N n -t timeout'' saves partial input only when EOF is seen?

2016-11-24 Thread Chet Ramey
On 11/24/16 2:57 AM, Clark Wang wrote: > See following example: > > # echo $BASH_VERSION > 4.4.5(2)-release > # ( printf 12345 ) | ( read -t 1 -N 10 v; echo "<$v>" ) > <12345> > # ( printf 12345; sleep 2 ) | ( read -t 1 -N 10 v; echo "<$v>" ) > <> > # > > The second "read" did not save "12345" to

``read -N n -t timeout'' saves partial input only when EOF is seen?

2016-11-23 Thread Clark Wang
See following example: # echo $BASH_VERSION 4.4.5(2)-release # ( printf 12345 ) | ( read -t 1 -N 10 v; echo "<$v>" ) <12345> # ( printf 12345; sleep 2 ) | ( read -t 1 -N 10 v; echo "<$v>" ) <> # The second "read" did not save "12345" to "v". Is this a bug? -clark

Re: read builtin doesnt save partial reads on timeout

2016-06-07 Thread Chet Ramey
On 6/6/16 10:01 AM, George Schwab wrote: > Bash Version: 4.3 > Patch Level: 11 > Release Status: release > > Description: > The read builtin does not appear to save partial reads to the > variable when a timeout has occured. > This is contrary to the do

read builtin doesnt save partial reads on timeout

2016-06-06 Thread George Schwab
e67 #3 SMP Tue May 10 10:22:44 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 4.3 Patch Level: 11 Release Status: release Description: The read builtin does not appear to save partial reads to the variable when a timeout has occured. This is co

Re: "read" builtin: timeout vs. EOF

2011-12-19 Thread Chet Ramey
> > Does it really need to be in the help text, which is > > just a short reminder reference, as well? > > I think info about how "read -t" exits should be _moved_ from under > the -t discussion to the Exit Status section. Right now there is > complete documentation in one

Re: "read" builtin: timeout vs. EOF

2011-12-19 Thread Stephen Gildea
> The documentation already says "the exit status is greater than > 128 if the timeout is exceeded" in a couple of places. Oh, look at that, a mere four lines above the text I quoted. I guess I can downgrade this to a documentation request. > Doe

Re: "read" builtin: timeout vs. EOF

2011-12-19 Thread Chet Ramey
; > I would like to be able to distinguish the no-data conditions. In > particular I want to know whether I got a timeout or an end-of-file, > but as you can see, Bash is not documented to behave differently in > these two cases. > > As it happens, in Bash 4.2, "read" ex

Re: "read" builtin: timeout vs. EOF

2011-12-19 Thread Eric Blake
; > I would like to be able to distinguish the no-data conditions. In > particular I want to know whether I got a timeout or an end-of-file, > but as you can see, Bash is not documented to behave differently in > these two cases. > > As it happens, in Bash 4.2, "read"

"read" builtin: timeout vs. EOF

2011-12-18 Thread Stephen Gildea
I want to know whether I got a timeout or an end-of-file, but as you can see, Bash is not documented to behave differently in these two cases. As it happens, in Bash 4.2, "read" exits with status 1 on EOF and SIGALRM on timeout. This is just what I want. Can I count on this behavior? If

Re: TIMEOUT

2009-04-06 Thread Greg Wooledge
On Sat, Apr 04, 2009 at 08:37:32AM -0300, Sergio Charpinel Jr. wrote: > So, first of all, I'm trying to find a way to combine TMOUT variable with > vlock. What's vlock? > I just found a way to do this in zhs. And if it is not possible, I > need to set TIMEOUT just for roo

Re: TIMEOUT

2009-04-04 Thread Allodoxaphobia
On Sat, 4 Apr 2009 08:37:32 -0300, Sergio Charpinel Jr. wrote: > Hi, > I'm in this mailing list, and I dont know if I am in the right place. If it > doesnt, tell me. comp.unix.shell I know, it's not very intuitive... Jonesy -- Marvin L Jones| jonz | W3DHJ | linu

TIMEOUT

2009-04-04 Thread Sergio Charpinel Jr.
Hi, I'm in this mailing list, and I dont know if I am in the right place. If it doesnt, tell me. So, first of all, I'm trying to find a way to combine TMOUT variable with vlock. I just found a way to do this in zhs. And if it is not possible, I need to set TIMEOUT just for root, an

Re: timeout

2008-07-28 Thread Eric Blake
Mike gmail.com> writes: > > Hi, I have a question. > > Why is the "timeout" command disappearing from recent Linux > distributions? > I am referring to the command that allows a time limit to be set for > another command: > > # timeout 10 ftp ...

Re: timeout

2008-07-28 Thread Chet Ramey
Mike wrote: Hi, I have a question. Why is the "timeout" command disappearing from recent Linux distributions? [...] I don't think it is a bash built-in command, but why not? No demand. It's so trivial to do as a separate command. Chet -- ``The lyf so short,

timeout

2008-07-28 Thread Mike
Hi, I have a question. Why is the "timeout" command disappearing from recent Linux distributions? I am referring to the command that allows a time limit to be set for another command: # timeout 10 ftp ... It is useful to me. I don't think it is a bash built-in comma

ssh timeout

2007-05-24 Thread Lango
define a timeout value after which the script will no longer attempt to talk to the server and go on to the next server in the list. How can I accomplish that? Here is part of my script: - - - - - - 8< - - - - - until [ $done ] do read <&3 servername if [ $? !=

timeout option for read that restarts on type

2006-04-08 Thread Juuso Alasuutari
From: iuso To: bug-bash@gnu.org Subject: timeout option for read that restarts on type Configuration Information [Automatically generated, do not change]: Machine: i686 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCO