bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: IGNOREEOF is ineffective when holds a big integer


From: Chet Ramey
Subject: Re: IGNOREEOF is ineffective when holds a big integer
Date: Wed, 18 Jun 2025 09:16:50 -0400
User-agent: Mozilla Thunderbird

On 6/17/25 10:31 PM, shynur . wrote:
```
INT_MAX=`echo \`printf '%u' -1\`/2 | bc`
IGNOREEOF=INT_MAX
# Then I typed C-d, bash exited...
```

```
IGNOREEOF=127
# C-d, C-d, C-d, ...
```

Why doesn’t the first piece of code work as expected?

Because it's not the right way to determine INT_MAX, and results in a
negative number.

In Bash, what exactly is the INT_MAX that I can safely use anywhere?

INT_MAX=$(getconf INT_MAX)
UINT_MAX=$(getconf UINT_MAX)

POSIX doesn't specify a way to get the max value for an intmax_t, but
you can get LONG_MAX, which is often the right value.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]