From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gatech.edu (gatech.edu [130.207.244.244]) by werple.net.au (8.7/8.7.1) with SMTP id VAA22910 for ; Sun, 22 Oct 1995 21:05:32 +1000 (EST) Received: from euclid (euclid.skiles.gatech.edu) by gatech.edu with SMTP id AA17160 (5.65c/Gatech-10.0-IDA for ); Sun, 22 Oct 1995 07:00:40 -0400 Received: by euclid (5.x/SMI-SVR4) id AA11226; Sun, 22 Oct 1995 06:58:57 -0400 Old-Return-Path: Resent-Date: Sun, 22 Oct 1995 12:31:55 +0200 (EET) Old-Return-Path: From: "Zvi Har'El" Message-Id: <199510221031.MAA11438@leeor.technion.ac.il> Subject: Re: appendhistory and history file truncation To: duvall@dhduvall.student.Princeton.EDU (Danek Duvall) Date: Sun, 22 Oct 1995 12:31:55 +0200 (EET) Cc: zsh-users@math.gatech.edu In-Reply-To: <199510210758.DAA01183@dhduvall.student.Princeton.EDU> from "Danek Duvall" at Oct 21, 95 03:58:32 am Hebrew-Date: 28 Tishri 5756 - epyz'd ixyz gk Reply-To: "Zvi Har'El" X-Mailer: ELM [version 2.4 PL24] Mime-Version: 1.0 Content-Type: text/plain; charset=none Content-Transfer-Encoding: 8bit Resent-Message-Id: <"9p8QJ3.0.9l2.iFYYm"@euclid> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/111 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Sat Oct 21 09:58:32 1995, Danek Duvall wrote about ``appendhistory and history file truncation'': > > 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 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. > > > As far as I have been able to verify, this works for non-login shells. However, if I log out and then login again, the problem persists even after applying the patch. -- Dr. Zvi Har'El Department of Mathematics +972-4-294094(Phone) Technion - Israel Institute of Technology +972-4-324654(FAX) http://gauss.technion.ac.il/~rl Haifa 32000, ISRAEL ``If you can't say somethin' nice, don't say nothin' at all.''--Thumper (1942)