[Top][All Lists]

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

Re: Command history with several shell instances

From: Michael Siegel
Subject: Re: Command history with several shell instances
Date: Fri, 13 Dec 2019 20:59:15 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:68.0) Gecko/20100101 Thunderbird/68.2.2

Am 10.12.19 um 17:37 schrieb Chet Ramey:
> 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.

Right. This is why, in my tests, I first got rid of all Bash command
history in the "Alice" session (including the history file) and then
started the "Bob" session in parallel to "Alice", so both would have no
command history at all.

> […] 
> 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.

I've had another look at all of Bash's configuration files on my Void
Linux installation (~/.bash_profile, ~/.bashrc, /etc/profile,
/etc/profile.d/, /etc/bash/bashrc) and found no instance of
PROMPT_COMMAND being set nor any call to the `history` builtin.

However, someone in #voidlinux on Freenode pointed me to a post on that clarified the situation for me:

In a comment to the question asked there, someone also provided a link
to an archived message to this mailing list from 2016 where you have
explained the actual effect of "histappend" already:

So, problem solved.


reply via email to

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