tcsh-org / tcsh

This is a read-only mirror of the tcsh code repository.
https://www.tcsh.org/
Other
232 stars 42 forks source link

history -S in periodic alias drops last few commands from history #41

Closed eranl closed 3 months ago

eranl commented 2 years ago

If I set my periodic alias to 'history -S', then every time it is executed, the last few commands (I've noticed between one and six) that were issued in that shell get dropped from history (both in memory and in history file). It doesn't occur if I call history -S at the prompt. It also apparently doesn't occur if history file doesn't exist.

This issue has been present in the last few releases. It appears to not be present in 6.20.00. It might be related to #29.

version: tcsh 6.22.04 (Astron) 2021-04-26 (x86_64-unknown-cygwin) options wide,nls,dl,al,kan,sm,rh,color savehist: 5000 merge history file is at 5000 commands

suominen commented 2 years ago

By any chance might you have more than one tcsh running and saving to the same file at the same time? For instance, multiple shell windows (e.g. under X11, screen, or tmux) started at the same time might be sufficiently in sync that they all read the same old file, and merge only their own commands to it.

On second thought, it would require interacting with each shell close enough, which is less likely.

I just thought of that because this issue exists when multiple shells exit at the same time (such as ending a screen or X11 session).

eranl commented 2 years ago

Thanks for the comment. Forgot to mention: the problem occurs even if I have a single shell instance running.

suominen commented 2 years ago

Some suggestions for figuring this out:

eranl commented 2 years ago

Thanks for the suggestions.

* The change ([6bc746c](https://github.com/tcsh-org/tcsh/commit/6bc746caad28d0f1ffaf07a4ea1468e8efcc6d52)) to fix [regression: history -S no longer merges command history as described in tcsh man page #29](https://github.com/tcsh-org/tcsh/issues/29) is tiny. Could you try reverting it?

I don't have a build environment set up. If I'm not mistaken, #29 was a result of a previous change, possibly https://github.com/tcsh-org/tcsh/commit/c9757dd83f6c641dacddd58095cefc5ed21a3b42, which might be related as well.

* Could you try without `merge` and see if that makes a difference?

The issue seems to go away without 'merge'.

* Could you try the latest release (6.23.00) or the latest code in the `master` branch?

Still present in tcsh 6.23.00 (Astron) 2021-11-11 (x86_64-unknown-cygwin) options wide,nls,dl,al,kan,sm,rh,color

suominen commented 3 months ago

Hey, I think at long last this has been fixed with 991f66c95bcb35f7b6d8c25273fc86c9e2b2c6ec, so I'm closing this ticket. Please do reopen, if this does not work for you in 6.24.12 (or eventually later versions).