On Wed, Dec 03, 2025 at 08:14:31AM -0500, Greg Wooledge wrote:
> On Wed, Dec 03, 2025 at 19:59:09 +0700, Robert Elz wrote:
> > Date: Wed, 3 Dec 2025 12:15:17 +0100
> > From: =?UTF-8?B?TMOpYSBHcmlz?= <[email protected]>
> > Message-ID: <[email protected]>
> >
> > | Ok then why does Bash parses the string value into float for the TMOUT
> >
> > What makes you believe that it does? Just that it doesn't generate an
> > error? Can you actually detect the difference between a timeout of 3
> > seconds, and one of 3.14... seconds?
>
> hobbit:~$ TMOUT=3.5 bash -c 'echo "$TMOUT"; time read'
> 3.5
> real 3.503 user 0.000 sys 0.000
>
> Not ironclad proof, but very strong evidence.
>From the definition of the "read" builtin in bash's source code:
/* $TMOUT, if set, is the default timeout for read. */
if (have_timeout == 0 && (e = get_string_value ("TMOUT")))
{
code = uconvert (e, &ival, &uval, (char **)NULL);
if (code == 0 || ival < 0 || uval < 0)
tmsec = tmusec = 0;
else
{
tmsec = ival;
tmusec = uval;
}
}
This shows that the "read" builtin uses the string value of TMOUT and
converts it to an integer touple (ival, uval, i.e., the whole and
fractional parts) using the "uconvert" function.
--
Matti Andreas Kähäri
Uppsala, Sweden
.