#1150294 if HISTFILE is a symlink, history truncation silently breaks

Package:
bash
Source:
bash
Description:
GNU Bourne Again SHell
Submitter:
Trent W. Buck
Date:
2026-10-08 06:01:04 UTC
Severity:
normal
#1150294#5
Date:
2026-10-08 05:59:19 UTC
From:
To:
I think this is NotABugTM, but I was so surprised I had to write it down/up.
I think the appropriate response is "don't do that, then" and
maybe add a comment in the manpage e.g.

    HISTFILE should point to a regular file, not a symlink

Initially I noticed that every interactive bash process was 85MB RSS.
My ~/.bash_history was 24MB; moving it away fixed bash to be only 6MB RSS.
I increase HISTFILESIZE, but not THAT much.
Its oldest entry was from 2022, when my host was first built.

My ~/.bash_history is a symlink, and
I speculated bash was measuring the length of the symlink and
concluding "it's small enough, nothing to truncate".
i.e. stat vs lstat.

Attached is a test transcript showing truncation is silently skipped
when ~/.bash_history is a symlink to ~/.local/share/bash/history.

Digging through the code, I can't see anything in here:
https://sources.debian.org/src/bash/5.3-4/bashhist.c
I think the underlying issue is in readline:
https://sources.debian.org/src/readline/8.3-4/histfile.c#L572-L581
I think if HISTFILE points to a symlink, readline skips truncation entirely.
However I can't see where bashhist.c ever calls history_truncate_file, so
that may be entirely the wrong function.