[bug #68641] history -w and -a ignore HISTFILESIZE

anonymous <[email protected]>
Newsgroups gmane.comp.shells.bash.bugs
Message-ID <[email protected]>
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/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaowZuAAKCRCqLAuaBUf3
ThXpAQDjd4V7B6AKSSNLQI7ntTN5DOtwmE1hwYku2TtZbsYr8AEAg8LL33Isa7UY
27lKHy+h0ILbC3QCFIwyVZUynOpsTgo=
=+HuC
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.