NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: HISTFILE support for /bin/sh



    Date:        Fri, 5 Jul 2024 22:40:12 +0000 (UTC)
    From:        RVP <rvp%SDF.ORG@localhost>
    Message-ID:  <0cf35f96-0726-610b-61ce-7afef59a13bd%SDF.ORG@localhost>

  | Lovely, but, if you can, could you please arrange it so that the
  | history is written/appended before the EXIT trap handlers are run?

Actually, it is just the opposite, so that it is possible for the
exit trap to arrange for history to be saved, without having that
happen any other time.

  | Or provide a cmd to write out the history (non-append mode) in the
  | EXIT handler?

I think that will be possible; if HISTAPPEND gets set, the current
history buffer will be flushed to the file immediately - it needs to
be or history order wrt future commands would be broken.   If you
were to set HISTAPPEND=yes in the exit trap, then (assuming HISTFILE is
set of course) the history buffer would be flushed, and of course, by
the time the exit trap is run, no more commands are going to be read,
so (apart from causing the buffer to be flushed) turning HISTAPPEND
on wouldn't do anything else.   You'd want to leave it set to prevent
the shell from writing the history buffer again (destroying your work)
when the shell exits.

I haven't done it yet, but I could also make "unset HISTFILE" (if it
was previously set) write the buffer to its previous file name (simply
removing the filename as a history file without writing anything can be
done by assigning an empty string to HISTFILE).

I doubt the NetBSD shell will ever get all the history manipulation
stuff that bash has however.

kre




Home | Main Index | Thread Index | Old Index