On Fri, 5 Jul 2024, Robert Elz wrote:
I'm also just using the libedit (editline) history facilities - which is what sh has always used for its history. They have supported reading/writing files for ages, just sh didn't make use of that functionality [...]
Lovely, but, if you can, could you please arrange it so that the history is written/appended before the EXIT trap handlers are run? Or provide a cmd to write out the history (non-append mode) in the EXIT handler? I have a little script which I run in ~/.bash_logout which "compacts" ~/.bash_history, and I'd like to do the same for ~/.sh_history (or whatever). bash(1) isn't clear about the order of writing history vs. running ~/.bash_logout, so I do: ``` c=$(who | awk -vU=$(id -nu) '$1==U { c++ } END { print c }') if ((c == 1)) then history -a buniq.sh fi ``` in ~/.bash_logout. Ie. write the history first, then remove the duplicate entries. Thanks, -RVP