Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
appendhistory and history file truncation
- X-seq: zsh-users 107
- From: Danek Duvall <duvall@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- To: Zsh users list <zsh-users@xxxxxxxxxxxxxxx>
- Subject: appendhistory and history file truncation
- Date: Sat, 21 Oct 1995 03:58:32 -0400
I haven't seen this show up on the list, so I thought I'd chime in.
I'm having a problem wherein whenever I start up an invocation of zsh
(2.6 beta10), my history file gets wiped. It doesn't happen when
NO_RCS is set (if I do zsh -f). It seems that even though
APPENDHISTORY is set, savehistfile() ends up opening the file mode
O_TRUNC on line 1471 of hist.c (at least, I think this is the
culprit). Perhaps this line should be rewritten as the block in lines
1420-1423.
I checked beta11-test10, and it hasn't been fixed.
Here's a really straightforward patch to beta10, which *should* fix
the problem, though I haven't tested it. Rewrite as you wish, but I
think this is the right thing to do.
Thanks,
Danek
--- hist.c.orig Sat Oct 21 03:54:08 1995
+++ hist.c Sat Oct 21 03:56:30 1995
@@ -1468,7 +1468,11 @@
histnum++;
}
fclose(out);
- if ((out = fdopen(open(s, O_WRONLY | O_TRUNC, 0600), "w"))) {
+ if (app & 1)
+ out = fdopen(open(s, O_CREAT | O_WRONLY | O_APPEND, 0600), "a");
+ else
+ out = fdopen(open(s, O_CREAT | O_WRONLY | O_TRUNC, 0600), "w");
+ if (out) {
if (histnum < savehist)
for (i = 0; i < histnum; i++)
fprintf(out, "%s", store[i]);
--
Danek Duvall <duvall@xxxxxxxxxxxxxxxxxxxx> For my PGP key, send mail with
Computer Science, Princeton University subject "get pgp key" or look
http://lorien.princeton.edu/~duvall/ it up on the keyservers.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author