URL:
  <https://savannah.gnu.org/bugs/?68641>

                 Summary: history -w and -a ignore HISTFILESIZE
                   Group: The GNU Bourne-Again SHell
               Submitter: None
               Submitted: Mon 24 Aug 2026 10:15:13 AM UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Unlocked


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Mon 24 Aug 2026 10:15:13 AM UTC By: Anonymous
HISTFILESIZE is only applied on shell launch and shell exit, when calling
`history -w` or `history -a` the file is not truncated at all. Meanwhile the
reference clearly states "The history file is also truncated to this size
after writing it when a shell exits or by the history builtin. "

Example: (.bashrc is empty)
```
[ilya@arch ~]$ history
    1  1
    2  2
    3  3
    4  4
    5  5
    6  history
[ilya@arch ~]$ HISTFILESIZE=5
[ilya@arch ~]$ history -w
[ilya@arch ~]$ cat .bash_history
1
2
3
4
5
history
HISTFILESIZE=5
history -w
```
Observe that `history -w` wrote the whole history. Same with `history -a`
Now we exit and reopen the shell and see that `exit` respected HISTFILESIZE
```
[ilya@arch ~]$ cat .bash_history
history
HISTFILESIZE=5
history -w
cat .bash_history
exit
```
Potential fix:
https://codeberg.org/ilya-the-human/bash-fixes/commit/521b9055742c43d3bad4e151241222cd046088ac







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68641>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

  • [bug #68641] h... anonymous
    • Re: [bug ... FĂ©lix Hauri via Bug reports for the GNU Bourne Again SHell

Reply via email to