* bug#33460: 24.4; Eshell histfile symlinks not followed
@ 2018-11-21 23:09 Philip Hudson
2018-11-24 0:16 ` bug#33477: 24.4; Eshell history/lastdir file " Philip Hudson
2018-12-08 9:15 ` bug#33460: 24.4; Eshell histfile " Eli Zaretskii
0 siblings, 2 replies; 4+ messages in thread
From: Philip Hudson @ 2018-11-21 23:09 UTC (permalink / raw)
To: 33460
[-- Attachment #1: Type: text/plain, Size: 767 bytes --]
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
[-- Attachment #2: eshellResolveHistFile.patch --]
[-- Type: text/x-patch, Size: 1266 bytes --]
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 ()
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#33477: 24.4; Eshell history/lastdir file symlinks not followed
2018-11-21 23:09 bug#33460: 24.4; Eshell histfile symlinks not followed Philip Hudson
@ 2018-11-24 0:16 ` Philip Hudson
2018-12-08 9:20 ` Eli Zaretskii
2018-12-08 9:15 ` bug#33460: 24.4; Eshell histfile " Eli Zaretskii
1 sibling, 1 reply; 4+ messages in thread
From: Philip Hudson @ 2018-11-24 0:16 UTC (permalink / raw)
To: 33477
[-- Attachment #1: Type: text/plain, Size: 1266 bytes --]
Expanding on bug #33460 (see below), predictably enough, the same
issue applies to eshell's "lastdir" file too.
The attached patch provides the same fix, again using function
`file-truename'. It supplants my previous patch, which should be
discarded. So I guess bug #33640 should be closed now.
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
---------- Forwarded message ---------
From: Philip Hudson <phil.hudson@iname.com>
Date: Wed, 21 Nov 2018 at 23:09
Subject: 24.4; Eshell histfile symlinks not followed
To: <bug-gnu-emacs@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.
--
Phil Hudson http://hudson-it.ddns.net
Pretty Good Privacy (PGP) ID: 0x4E482F85
[-- Attachment #2: eshellResolveHistAndDirsFile.patch --]
[-- Type: text/x-patch, Size: 2441 bytes --]
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el
index b7d13ee..c16a5ac 100644
--- a/lisp/eshell/em-dirs.el
+++ b/lisp/eshell/em-dirs.el
@@ -552,15 +552,16 @@ in the minibuffer:
(defun eshell-write-last-dir-ring ()
"Write the buffer's `eshell-last-dir-ring' to a history file."
- (let ((file eshell-last-dir-ring-file-name))
+ (let* ((file eshell-last-dir-ring-file-name)
+ (resolved-file (file-truename file)))
(cond
((or (null file)
(equal file "")
(null eshell-last-dir-ring)
(ring-empty-p eshell-last-dir-ring))
nil)
- ((not (file-writable-p file))
- (message "Cannot write last-dir-ring file %s" file))
+ ((not (file-writable-p resolved-file))
+ (message "Cannot write last-dir-ring file %s" resolved-file))
(t
(let* ((ring eshell-last-dir-ring)
(index (ring-length ring)))
@@ -570,7 +571,7 @@ in the minibuffer:
(insert (ring-ref ring index) ?\n))
(insert (eshell/pwd) ?\n)
(eshell-with-private-file-modes
- (write-region (point-min) (point-max) file nil
+ (write-region (point-min) (point-max) resolved-file nil
'no-message))))))))
(provide 'em-dirs)
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 ()
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#33460: 24.4; Eshell histfile symlinks not followed
2018-11-21 23:09 bug#33460: 24.4; Eshell histfile symlinks not followed Philip Hudson
2018-11-24 0:16 ` bug#33477: 24.4; Eshell history/lastdir file " Philip Hudson
@ 2018-12-08 9:15 ` Eli Zaretskii
1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2018-12-08 9:15 UTC (permalink / raw)
To: Philip Hudson; +Cc: 33460-done
> From: Philip Hudson <phil.hudson@iname.com>
> 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).
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#33477: 24.4; Eshell history/lastdir file symlinks not followed
2018-11-24 0:16 ` bug#33477: 24.4; Eshell history/lastdir file " Philip Hudson
@ 2018-12-08 9:20 ` Eli Zaretskii
0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2018-12-08 9:20 UTC (permalink / raw)
To: Philip Hudson; +Cc: 33477-done
> From: Philip Hudson <phil.hudson@iname.com>
> Date: Sat, 24 Nov 2018 00:16:14 +0000
>
> Expanding on bug #33460 (see below), predictably enough, the same
> issue applies to eshell's "lastdir" file too.
Thanks. You should have written to the 33460 bug address, not opening
a new bug.
> The attached patch provides the same fix, again using function
> `file-truename'. It supplants my previous patch, which should be
> discarded. So I guess bug #33640 should be closed now.
I pushed both changes to the master branch. As mentioned earlier,
please in the future provide commit log messages and the necessary
documentation changes.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-08 9:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-21 23:09 bug#33460: 24.4; Eshell histfile symlinks not followed Philip Hudson
2018-11-24 0:16 ` bug#33477: 24.4; Eshell history/lastdir file " Philip Hudson
2018-12-08 9:20 ` Eli Zaretskii
2018-12-08 9:15 ` bug#33460: 24.4; Eshell histfile " Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.