Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: locking failed for /home/whoever/.zhistory: no such file or directory
On Wed, 13 Jul 2011 07:54:44 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Jul 13, 3:01pm, Peter Stephenson wrote:
> } Subject: Re: locking failed for /home/whoever/.zhistory: no such file or d
> }
> } > But my .zhistory is always empty.
> }
> } Is there a good reason you need to have the .zhistory file even though
> } it's empty?
>
> I think he means zsh is never writing anything to the file, not that it
> is intentionally always empty.
That's not related to the locking problem, though, is it?
It's very easy to ignore empty files completely. We always stat anyway
in the "fast" case, so this only adds the operation in the normal case,
where an extra stat is lost in the noise.
Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.113
diff -p -u -r1.113 hist.c
--- Src/hist.c 12 Jul 2011 08:37:11 -0000 1.113
+++ Src/hist.c 13 Jul 2011 18:50:15 -0000
@@ -2246,10 +2246,12 @@ readhistfile(char *fn, int err, int read
if (!fn && !(fn = getsparam("HISTFILE")))
return;
+ if (stat(unmeta(fn), &sb) < 0 ||
+ sb.st_size == 0)
+ return;
if (readflags & HFILE_FAST) {
- if (stat(unmeta(fn), &sb) < 0
- || (lasthist.fsiz == sb.st_size && lasthist.mtim == sb.st_mtime)
- || lockhistfile(fn, 0))
+ if ((lasthist.fsiz == sb.st_size && lasthist.mtim == sb.st_mtime)
+ || lockhistfile(fn, 0))
return;
lasthist.fsiz = sb.st_size;
lasthist.mtim = sb.st_mtime;
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author