Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] zexit: don't write history in sub-shells
- X-seq: zsh-workers 54930
- From: dana <dana@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] zexit: don't write history in sub-shells
- Date: Wed, 08 Jul 2026 21:56:52 -0500
- Archived-at: <https://zsh.org/workers/54930>
- Feedback-id: i9be146f9:Fastmail
- List-id: <zsh-workers.zsh.org>
i noticed this:
% read -t10 -k1 &
[1] 13722
[1] + suspended (tty output) read -t10 -k1
% kill -HUP %%
zsh: locking failed for /.../.zhistory: file exists
[1] + exit 1 read -t10 -k1
i think the lock failure is because both the sub-shell exiting and the
command executing want to save the history
in any case, i'm not sure why we should write the history out when a
sub-shell exits at all. is there a reason i'm not considering?
dana
diff --git a/Src/builtin.c b/Src/builtin.c
index b3a735fd4..6c7633dbf 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -6067,7 +6067,7 @@ zexit(int val, enum zexit_t from_where)
killrunjobs(from_where == ZEXIT_SIGNAL);
}
cleanfilelists();
- if (isset(RCS) && interact) {
+ if (isset(RCS) && interact && !subsh) {
if (!nohistsave) {
int writeflags = HFILE_USE_OPTIONS;
if (from_where == ZEXIT_SIGNAL)
@@ -6075,7 +6075,7 @@ zexit(int val, enum zexit_t from_where)
saveandpophiststack(1, writeflags);
savehistfile(NULL, 1, writeflags);
}
- if (islogin && !subsh) {
+ if (islogin) {
sourcehome(".zlogout");
#ifdef GLOBAL_ZLOGOUT
if (isset(RCS) && isset(GLOBALRCS))
Messages sorted by:
Reverse Date,
Date,
Thread,
Author