help-bash
[Top][All Lists]
Advanced

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

Re: Command history with several shell instances


From: Chet Ramey
Subject: Re: Command history with several shell instances
Date: Tue, 10 Dec 2019 11:37:34 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.3.0

On 12/8/19 6:11 AM, Michael Siegel wrote:
Hello,

I have a question on how Bash handles preserving the command history in
~/.bash_history when several shell instances are used in parallel. I was
expecting the history file to be overwritten every time a shell instance
is terminated because bash(1) says:

If the histappend shell option is enabled (see the description of shopt
under SHELL BUILTIN COMMANDS below), the lines are appended to the
history file, otherwise the history file is overwritten.

Bash manages its per-shell-instance history list in memory. It reads from
the history file at startup and writes to it on exit.

The histappend option operates when the shell writes the history at exit.

However, this doesn't seem to be the case even though `shopt | grep
histappend` gives me "histappend off" on both systems I have tested this
on, which are Devuan running Bash 4.4.12 and Void Linux running Bash 5.0.11.

The following is a record of the test I ran using three terminal
emulator windows under X. (I also ran this on TTYs on Void Linux.)

There are options to the `history' builtin that will read entries from the
history file and write entries to it. Some distributions use the
PROMPT_COMMAND variable and a combination of calls to `history' to effect a
shared history file that is updated after each command.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]