unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#36004: [PATCH] Eshell does not extend correctly PATH by "." on MS-Windows
@ 2019-05-30 11:40 Bernhard Rotter
  2019-06-08  8:33 ` Eli Zaretskii
  2019-06-08  8:34 ` Eli Zaretskii
  0 siblings, 2 replies; 3+ messages in thread
From: Bernhard Rotter @ 2019-05-30 11:40 UTC (permalink / raw)
  To: 36004

[-- Attachment #1: Type: text/plain, Size: 729 bytes --]

Eshell uses eshell-parse-colon-path to split $PATH. The paths returned have a
slash appended, so an absolute path can be contructed simply by concatenating
path and filename. On windows the result list of eshell-parse-colon-path is
extended further by "." (without a slash).

This was no problem for me until I wanted to run git in a directory created by
"git worktree add". When eshell was looking for git it found the file ".git"
whereas it should have been looking for "./git". The result was an error
message.

In GNU Emacs 26.2 (build 1, x86_64-w64-mingw32)
 of 2019-04-13 built on CIRROCUMULUS
Repository revision: fd1b34bfba8f3f6298df47c8e10b61530426f749
Windowing system distributor 'Microsoft Corp.', version 10.0.17763

[-- Attachment #2: 0001-Fix-path-for-current-directory-in-eshell-on-MS-Windo.patch --]
[-- Type: application/octet-stream, Size: 2738 bytes --]

From fb6088c709e5315ab2c9d241c0bd8d4a655dd2c2 Mon Sep 17 00:00:00 2001
From: Bernhard Rotter <bernhard.rotter@gmail.com>
Date: Thu, 30 May 2019 10:13:00 +0200
Subject: [PATCH] Fix path for current directory in eshell on MS-Windows

* lisp/eshell/em-cmpl.el (eshell-complete-commands-list):
* lisp/eshell/esh-ext.el (eshell-search-path):
On MS-Windows PATH is extended by current directory.  Do it right by using the
path prefix "./" instead of "." just as the other PATH components (refactored
to eshell-get-path).
* lisp/eshell/esh-util.el (eshell-get-path): New function.
---
 lisp/eshell/em-cmpl.el  | 4 +---
 lisp/eshell/esh-ext.el  | 4 +---
 lisp/eshell/esh-util.el | 8 ++++++++
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index f834882f7b..2246b65220 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -408,13 +408,11 @@ eshell-complete-commands-list
 	  (setq filename (substring filename 1)
 		pcomplete-stub filename
 		glob-name t))
-      (let* ((paths (eshell-parse-colon-path eshell-path-env))
+      (let* ((paths (eshell-get-path))
 	     (cwd (file-name-as-directory
 		   (expand-file-name default-directory)))
 	     (path "") (comps-in-path ())
 	     (file "") (filepath "") (completions ()))
-        (if (eshell-under-windows-p)
-            (push "." paths))
 	;; Go thru each path in the search path, finding completions.
 	(while paths
 	  (setq path (file-name-as-directory
diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el
index fccdb73b31..33415b0504 100644
--- a/lisp/eshell/esh-ext.el
+++ b/lisp/eshell/esh-ext.el
@@ -79,10 +79,8 @@ eshell-search-path
   "Search the environment path for NAME."
   (if (file-name-absolute-p name)
       name
-    (let ((list (eshell-parse-colon-path eshell-path-env))
+    (let ((list (eshell-get-path))
 	  suffixes n1 n2 file)
-      (if (eshell-under-windows-p)
-          (push "." list))
       (while list
 	(setq n1 (concat (car list) name))
 	(setq suffixes eshell-binary-suffixes)
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index f8dd6f08f4..8cbb8f31c9 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -232,6 +232,14 @@ eshell-path-env
 `default-directory' points to a remote host.")
 (make-variable-buffer-local 'eshell-path-env)
 
+(defun eshell-get-path ()
+  "Return $PATH as list.
+Add the current directory on windows."
+  (eshell-parse-colon-path
+   (if (eshell-under-windows-p)
+       (concat "." path-separator eshell-path-env)
+     eshell-path-env)))
+
 (defun eshell-parse-colon-path (path-env)
   "Split string with `parse-colon-path'.
 Prepend remote identification of `default-directory', if any."
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#36004: [PATCH] Eshell does not extend correctly PATH by "." on MS-Windows
  2019-05-30 11:40 bug#36004: [PATCH] Eshell does not extend correctly PATH by "." on MS-Windows Bernhard Rotter
@ 2019-06-08  8:33 ` Eli Zaretskii
  2019-06-08  8:34 ` Eli Zaretskii
  1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2019-06-08  8:33 UTC (permalink / raw)
  To: Bernhard Rotter; +Cc: 36004

> From: Bernhard Rotter <bernhard.rotter@gmail.com>
> Date: Thu, 30 May 2019 13:40:02 +0200
> 
> Eshell uses eshell-parse-colon-path to split $PATH. The paths returned have a
> slash appended, so an absolute path can be contructed simply by concatenating
> path and filename. On windows the result list of eshell-parse-colon-path is
> extended further by "." (without a slash).
> 
> This was no problem for me until I wanted to run git in a directory created by
> "git worktree add". When eshell was looking for git it found the file ".git"
> whereas it should have been looking for "./git". The result was an error
> message.

Thanks, pushed to the master branch.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#36004: [PATCH] Eshell does not extend correctly PATH by "." on MS-Windows
  2019-05-30 11:40 bug#36004: [PATCH] Eshell does not extend correctly PATH by "." on MS-Windows Bernhard Rotter
  2019-06-08  8:33 ` Eli Zaretskii
@ 2019-06-08  8:34 ` Eli Zaretskii
  1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2019-06-08  8:34 UTC (permalink / raw)
  To: 36004-done

Closing.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-08  8:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30 11:40 bug#36004: [PATCH] Eshell does not extend correctly PATH by "." on MS-Windows Bernhard Rotter
2019-06-08  8:33 ` Eli Zaretskii
2019-06-08  8:34 ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).