Tracking down a Zsh history data loss bug

(michael.stapelberg.ch)

45 points | by ingve 5 hours ago

6 comments

  • mmh0000 3 hours ago
    I have nearly a decade of zsh history. Reading that article I came to the conclusion that I may have been hit by that bug in the past but I haven’t noticed.

    Then I kept reading and the author mentions accidentally exporting HISTFILE[1] and I screamed in terror and ran to my computer as I realized a mistake I’ve been making for…ever.

    I am now both happy and sad I read this article.

    [1] https://github.com/stapelberg/configfiles/commit/32dcda0f49a...

    • PyWoody 1 hour ago
      I'm always curious what people get out of their terminal history. About 98% of mine is embarrassing and made for the ether.

      Have you ever looked back on your history?

      • unsnap_biceps 46 minutes ago
        I do to find a command that I know I ran that did something but I don't remember exactly how I did it. It's rare, but it's useful to be able to.
      • fragmede 46 minutes ago
        With Atuin, I hit ctrl-r and go to directory mode, and get the commands I ran the last time I was in that directory.
      • TacticalCoder 49 minutes ago
        > About 98% of mine is embarrassing and made for the ether.

        Same

        > Have you ever looked back on your history?

        All the time? I search in my history, re-launch past commands, etc.

        Now it's typically recent history, usually same day.

        I know about the shortcuts etc. but I also need to at times pipe history into other commands so I've got a two letters alias:

            h?
        
        Which greps into my history. I use that h? all the time.
  • myshapeprotocol 48 minutes ago
    Tracking down subtle data loss edge cases in shell history internals requires absolute precision. Great debugging write-up.
  • aclindsa 3 hours ago
    Nice work! I have felt like I lost zsh history before but never looked into it.
  • fragmede 1 hour ago
    Are people not just using http://atuin.sh these days?
    • a2ff6eeb0 1 hour ago
      Nah. I don't use the shell anymore. Claude knows how to use it better than I do.
  • TZubiri 2 hours ago
    Does zsh have that 2000 command limit by default?

    You can't expect much from a system that has those defaults, I'm all for traditions, but if I were to depend on a system for command history, it wouldn't be anything that reads a bash_history, a revolution is needed, not incremental optimizations

    P.s: what I do is set it to unlimited on both size and line count, but it's not a forensic grade audit trace, we'd need an OS, or ssh command logger, preferably one that writes to an external disk, but it can be to a root controlled file, definitely not to a user owned file.

    Security protects not only against attackers, but against bugs, a user's command history should not be deletable by user. Anything else is a wrong architecture that we are just carrying by inertia and laziness.

  • kevinbaiv 3 hours ago
    [dead]