In variables.c at line 6243 we have
eof_encountered_limit = (*temp && all_digits (temp)) ? atoi (temp) : 10;

Presumably in your build of Bash, as in mine, `int` is 32-bit, so the
maximum value convertible by atoi would be 2147483647.
Larger values are returned modulo 4294967296 (with 2's complement sign
handling).
atoi("9223372036854775807") returns -1.

(This does not limit the range that printf can handle; it will normally
cope with at least 64-bit (the size of `intmax_t` and/or `long int`).

Whilst there's arguably a bug, attempting to set IGNOREEOF to a very large
number seems to indicate a misunderstanding of its intended purpose.

The point is that IGNOREEOF should be set so that the user does not
inadvertently log themselves out by pressing ^D too many times (e.g. while
trying to terminate input to some other program). It should NOT be
"infinite" or "large", otherwise Bash will simply spin forever after the
client device has nothing more to give; consider what happens if one types:
« bash -i </dev/null »
Most people would want this to give up, eventually, since it can't be
interrupted with ^C or ^Z, but with IGNOREEOF=1000000 this takes an
uncomfortably long time to quit. Bigger numbers just cause more harm than
good.

Most keyboards don´t auto-repeat faster than about 30 characters per second
on most keyboards, so setting say IGNOREEOF=65535 would prevent you from
logging out until you've held down your ^D key for more than half an hour.

Setting IGNOREEOF to a few hundred seems entirely reasonable for most
people.

-Martin

On Wed, 18 Jun 2025 at 12:31, shynur . <one.last.k...@outlook.com> 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?
>
> In Bash, what exactly is the INT_MAX that I can safely use anywhere?
>
> --
> shynur
>

Reply via email to