Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15294

Re: History not saved when closing terminal while bash is sourcing a script

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: History not saved when closing terminal while bash is sourcing a script
Date 2019-08-04 13:42 -0400
Organization ITS, Case Western Reserve University
Message-ID <mailman.840.1564940540.1985.bug-bash@gnu.org> (permalink)
References <20190803150529.u5lf2tzvgo5sie7m@nomi.cz> <2b96a07b-c679-ea90-a714-056c81ee0c97@case.edu>

Show all headers | View raw


On 8/3/19 11:05 AM, Tomas Janousek wrote:
> Hello,
> 
> today I was wondering why I'm sometimes losing history entries and found out
> that bash (5.0.3(1)-release, on Debian testing) won't save the history file
> on closing the terminal window if it's currently sourcing something. I'm
> attaching a script that uses tmux to simulate the scenario. On my system, only
> "test 1" is printed, not "test 2" as expected. I think this is a bug.

I don't have or use tmux, but I'm going to guess that `kill-window' sends
a SIGHUP to the process group and follows it up with a SIGKILL. The
`source' turns off saving to history -- the `source' gets saved in the
history list, not the commands it runs -- and is still running when the
SIGHUP arrives. The SIGHUP causes the shell to exit without saving the
history because history is turned off when the signal handler runs.

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

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: History not saved when closing terminal while bash is sourcing a script Chet Ramey <chet.ramey@case.edu> - 2019-08-04 13:42 -0400

csiph-web