Tracking down a Zsh history data loss bug

michael.stapelberg.ch
August 15, 2026
23 min read
🔥🔥🔥🔥🔥
52/100
Summary
Zsh 5.9.2, released on July 12, 2026, includes a fix for a bug that caused data loss in the Z shell history file. The bug was tracked down by patching Zsh to crash loudly and analyzing the core dump from the crash.
Key Takeaways
- Zsh 5.9.2, released on July 12, 2026, includes a fix for a history data loss bug that caused recent commands to disappear from the shell history file.
- The author tracked the bug by using file system change monitoring tools like inotify, which revealed that Zsh was deleting and recreating the history file during operation.
- The author's Zsh configuration allows for a large history size and prevents sharing of history entries between separate shell sessions.
- The issue persisted despite the absence of visible corruption in the .zsh_history file, prompting further investigation into the cause of the truncation.
Coverage & discussions
Hacker News · michael.stapelberg.ch
Community discussions
Community Sentiment
Positives
- Zsh has some fantastic customizations that make managing command history a breeze, which is a game changer for many users.
- I'm relieved to finally understand my long-standing issue with exported HISTFILE; this article has saved me from future history loss.
- The fix proposed in the article is appreciated, especially for those of us who have been backing up our history files due to past bugs.
Concerns
- The history loss bug is frustrating and has been a persistent issue for users, leading to a lot of lost data and confusion.
- Using Bash was a nightmare with history loss, and many commenters are fed up with these recurring issues across shells.
- Overcomplicated solutions in Zsh can sometimes create more problems than they solve, leaving users to deal with unnecessary complexity.




