zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Cc: Sven Joachim <svenjoac@gmx.de>, 369305@bugs.debian.org
Subject: Re: Bug#369305: zsh: failed to write history file /home/sven/.zsh-history: no such file or directory
Date: Thu, 6 Mar 2008 10:19:37 +0000	[thread overview]
Message-ID: <20080306101937.6e4bd8a7@news01> (raw)
In-Reply-To: <20080305224158.GB9620@herod.dreamhost.com>

On Wed, 5 Mar 2008 14:41:58 -0800
Wayne Davison <wayned@users.sourceforge.net> wrote:
> On Wed, Mar 05, 2008 at 03:29:36PM -0500, Clint Adams wrote:
> > As Sven notes, any history added before exiting will make it into the
> > history file despite the error message.
> 
> The history being added is the appending going on due to SHARE_HISTORY.
> The error is referring to the inability to rewrite the history file on
> exit, and it is actually failing (because the write-new, then rename
> steps would cause the file to change ownership).  If incremental history
> updating was not happening, the failed rewrite would indeed not save
> anything new.  The "no such file or directory" error string is
> presumably a left-over errno that Peter noticed.

Yes, I've found where... at this point we've already handled the error in
the manner you say by simply not trying to write the history, so there's no
system error we haven't dealt with and we should reset errno.

We could fix both problems by not printing an error if there's no "errno",
as below.  That's OK in the specific circumstances, but probably not right
in all cases.  Could we, for example, pass down a flag when savehistfile()
is called from itself to do the rewriting and suppress the error message,
or make it more anodyne, in that case?

If we decide a warning message is still appropriate, given that we've
detected exactly what's going on it should probably be more specific than
just a vague "failed to write history".

I won't commit this until we've resolved the TODO, but you might want to
check it does remove the error message.

Index: Src/hist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hist.c,v
retrieving revision 1.70
diff -u -r1.70 hist.c
--- Src/hist.c	31 Dec 2007 23:14:17 -0000	1.70
+++ Src/hist.c	6 Mar 2008 10:16:08 -0000
@@ -2207,7 +2207,13 @@
 	    struct stat sb;
 	    int old_exists = stat(unmeta(fn), &sb) == 0;
 
+	    errno = 0;
 	    if (old_exists && sb.st_uid != geteuid()) {
+		/*
+		 * TODO: do we want an error message about changed ownership
+		 * here?  Do we want a lesser error message, or none,
+		 * if this call to savehistfile() was just a rewrite?
+		 */
 		free(tmpfile);
 		tmpfile = NULL; /* Avoid an error about HISTFILE.new */
 		out = NULL;
@@ -2302,7 +2308,7 @@
     } else
 	ret = -1;
 
-    if (ret < 0 && err) {
+    if (ret < 0 && err && errno) {
 	if (tmpfile) {
 	    zerr("failed to write history file %s.new: %e", fn, errno);
 	    free(tmpfile);

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


  reply	other threads:[~2008-03-06 10:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87ir01bb68.fsf@gmx.de>
2008-03-05 14:44 ` Clint Adams
2008-03-05 17:12   ` Peter Stephenson
2008-03-05 20:29     ` Clint Adams
2008-03-05 22:41       ` Wayne Davison
2008-03-06 10:19         ` Peter Stephenson [this message]
2008-03-06 17:02           ` Wayne Davison
2008-03-06 17:16             ` Wayne Davison

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=20080306101937.6e4bd8a7@news01 \
    --to=pws@csr.com \
    --cc=369305@bugs.debian.org \
    --cc=svenjoac@gmx.de \
    --cc=zsh-workers@sunsite.dk \
    /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).