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

Félix Hauri via Bug reports for the GNU Bourne Again SHell <[email protected]>
Newsgroups gmane.comp.shells.bash.bugs
Message-ID <[email protected]>
Le Mon, Aug 24, 2026 at 06:15:20AM -0400, anonymous a écrit :
> -------------------------------------------------------
> 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
> ```

There seem to be alwost two alternatives:

 1 ) export HISTFILESIZE

 2 ) run command history -w as:
     HISTFILESIZE=5 history -w

-- 
 Félix Hauri  -  <[email protected]>  -  http://www.f-hauri.ch
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.