From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: <zsh-users@zsh.org>
Subject: Re: locking failed for /home/whoever/.zhistory: no such file or directory
Date: Wed, 13 Jul 2011 19:53:29 +0100 [thread overview]
Message-ID: <20110713195329.1fdc1b35@pws-pc.ntlworld.com> (raw)
In-Reply-To: <110713075444.ZM13017@torch.brasslantern.com>
On Wed, 13 Jul 2011 07:54:44 -0700
Bart Schaefer <schaefer@brasslantern.com> 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@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
next prev parent reply other threads:[~2011-07-13 19:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-10 14:22 Cesar Romani
2011-07-10 16:53 ` Peter Stephenson
2011-07-13 13:50 ` Cesar Romani
2011-07-13 14:01 ` Peter Stephenson
2011-07-13 14:54 ` Bart Schaefer
2011-07-13 18:53 ` Peter Stephenson [this message]
2011-07-14 15:04 ` Bart Schaefer
2011-07-10 17:13 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110713195329.1fdc1b35@pws-pc.ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).