GNU bug report logs - #47547
28.0.50; [PATCH] Eshell cannot 'cd' in directory with 'eshell' as name

Previous Next

Package: emacs;

Reported by: Utkarsh Singh <utkarsh190601 <at> gmail.com>

Date: Thu, 1 Apr 2021 14:50:02 UTC

Severity: normal

Tags: fixed, patch

Found in version 28.0.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 47547 in the body.
You can then email your comments to 47547 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#47547; Package emacs. (Thu, 01 Apr 2021 14:50:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Utkarsh Singh <utkarsh190601 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 01 Apr 2021 14:50:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Utkarsh Singh <utkarsh190601 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; [PATCH] Eshell cannot 'cd' in directory with 'eshell' as name
Date: Thu, 01 Apr 2021 20:22:05 +0530
Reproduce the error:

(setq eshell-cd-on-directory t) ; in-case you have changed the defaults

Invoke eshell and enter the following commands:

$ /usr/local/share/emacs/28.0.50/lisp/eshell
Read error: Is a directory, /usr/local/share/emacs/28.0.50/lisp/eshell

OR

$ mkdir /tmp/eshell
$ /tmp/eshell
Read error: Is a directory, /tmp/eshell/

So where is the problem?

Checking `eshell-interpreter-alist' value:
((eshell-visual-command-p . eshell-exec-visual)
 ((closure
   (t)
   (file _args)
    (string= (file-name-nondirectory file)
    "eshell"))
  . eshell/source)
 (#f(compiled-function
     (file args)
     #<bytecode -0x47e9576cc9960d2>)
    . eshell-dirs-substitute-cd))
    
We can see eshell is using `file-name-nondirectory' to source file which
leads to the read error.  I suggest to add one more check before
loading file from `eshell/source'. One example of such check is
`file-regular-p' check and hence I drafted this patch.

diff --git a/lisp/eshell/em-script.el b/lisp/eshell/em-script.el
index aecc48610f..6e6ae1229e 100644
--- a/lisp/eshell/em-script.el
+++ b/lisp/eshell/em-script.el
@@ -60,8 +60,9 @@ eshell-script-initialize
   "Initialize the script parsing code."
   (setq-local eshell-interpreter-alist
 	(cons (cons #'(lambda (file _args)
-                        (string= (file-name-nondirectory file)
-                                 "eshell"))
+                        (and (file-regular-p file)
+                             (string= (file-name-nondirectory file))
+                             "eshell"))
                     'eshell/source)
 	      eshell-interpreter-alist))
   (setq-local eshell-complex-commands
-- 
Utkarsh Singh
utkarshsingh.xyz




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47547; Package emacs. (Mon, 05 Apr 2021 16:05:01 GMT) Full text and rfc822 format available.

Message #8 received at 47547 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Utkarsh Singh <utkarsh190601 <at> gmail.com>
Cc: 47547 <at> debbugs.gnu.org
Subject: Re: bug#47547: 28.0.50; [PATCH] Eshell cannot 'cd' in directory
 with 'eshell' as name
Date: Mon, 05 Apr 2021 18:04:43 +0200
Utkarsh Singh <utkarsh190601 <at> gmail.com> writes:

> We can see eshell is using `file-name-nondirectory' to source file which
> leads to the read error.  I suggest to add one more check before
> loading file from `eshell/source'. One example of such check is
> `file-regular-p' check and hence I drafted this patch.

Thanks; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 05 Apr 2021 16:05:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 47547 <at> debbugs.gnu.org and Utkarsh Singh <utkarsh190601 <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 05 Apr 2021 16:05:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 04 May 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 355 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.