Subject: bug#33460: closed (Re: bug#33460: 24.4; Eshell histfile symlinks not followed)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 08 Dec 2018 09:16:02 +0000

Your bug report

#33460: 24.4; Eshell histfile symlinks not followed

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
33460: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=33460
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#33460: 24.4; Eshell histfile symlinks not followed
From: Eli Zaretskii <[email-masked]>
To: Philip Hudson <[email-masked]>
Cc: [email-masked]
Date: Sat, 08 Dec 2018 11:15:27 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Philip Hudson <[email-masked]>
> Date: Wed, 21 Nov 2018 23:09:16 +0000
> 
> If the file named by the value of option `eshell-history-file-name' is
> a symbolic link, then it will be replaced and overwritten instead. It
> should be dereferenced (followed) first, and its target file should be
> replaced and overwritten.
> 
> The attached patch uses function `file-truename' to fix this. The
> patch was made using source cloned from git savannah HEAD today, which
> I think is version 26.1.90, based on ChangeLog.3 in the cloned repo.

Thanks, pushed to the master branch, to appear in Emacs 27.1.

Please in the future provide a ChangeLog-style commit log entry for
your changes; see CONTRIBUTE for the details.

Also, user-visible behavior changes need to be called out in NEWS, and
if necessary also in the relevant Texinfo manual(s).

Subject: 24.4; Eshell histfile symlinks not followed
From: Philip Hudson <[email-masked]>
To: [email-masked]
Date: Wed, 21 Nov 2018 23:09:16 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

If the file named by the value of option `eshell-history-file-name' is
a symbolic link, then it will be replaced and overwritten instead. It
should be dereferenced (followed) first, and its target file should be
replaced and overwritten.

The attached patch uses function `file-truename' to fix this. The
patch was made using source cloned from git savannah HEAD today, which
I think is version 26.1.90, based on ChangeLog.3 in the cloned repo.

In GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version 3.14.5)
of 2017-09-12 on hullmann, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11604000
System Description: LMDE 2 Betsy

-- 
Phil Hudson                  http://hudson-it.ddns.net
Pretty Good Privacy (PGP) ID: 0x4E482F85
diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el
index 62e2f57..f866dfd 100644
--- a/lisp/eshell/em-hist.el
+++ b/lisp/eshell/em-hist.el
@@ -466,15 +466,16 @@ lost if `eshell-history-ring' is not empty.  If
 Useful within process sentinels.
 
 See also `eshell-read-history'."
-  (let ((file (or filename eshell-history-file-name)))
+  (let* ((file (or filename eshell-history-file-name))
+	 (resolved-file (file-truename file)))
     (cond
      ((or (null file)
 	  (equal file "")
 	  (null eshell-history-ring)
 	  (ring-empty-p eshell-history-ring))
       nil)
-     ((not (file-writable-p file))
-      (message "Cannot write history file %s" file))
+     ((not (file-writable-p resolved-file))
+      (message "Cannot write history file %s" resolved-file))
      (t
       (let* ((ring eshell-history-ring)
 	     (index (ring-length ring)))
@@ -489,7 +490,7 @@ See also `eshell-read-history'."
               (insert (substring-no-properties (ring-ref ring index)) ?\n)
 	      (subst-char-in-region start (1- (point)) ?\n ?\177)))
 	  (eshell-with-private-file-modes
-	   (write-region (point-min) (point-max) file append
+	   (write-region (point-min) (point-max) resolved-file append
 			 'no-message))))))))
 
 (defun eshell-list-history ()