[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master d2abe91d4bf: In Eshell, don't expand quoted tildes into a user's
From: |
Jim Porter |
Subject: |
master d2abe91d4bf: In Eshell, don't expand quoted tildes into a user's home directory |
Date: |
Sun, 28 Jan 2024 19:04:06 -0500 (EST) |
branch: master
commit d2abe91d4bf68f20e4b1cd39f88ed98fd5731524
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>
In Eshell, don't expand quoted tildes into a user's home directory
* lisp/eshell/em-dirs.el (eshell-parse-user-reference): Don't expand
quoted tildes.
* test/lisp/eshell/em-dirs-tests.el
(em-dirs-test/expand-user-reference/local)
(em-dirs-test/expand-user-reference/quoted): New tests.
---
lisp/eshell/em-dirs.el | 1 +
test/lisp/eshell/em-dirs-tests.el | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el
index 85036620c57..07063afc286 100644
--- a/lisp/eshell/em-dirs.el
+++ b/lisp/eshell/em-dirs.el
@@ -262,6 +262,7 @@ Thus, this does not include the current directory.")
(defun eshell-parse-user-reference ()
"An argument beginning with ~ is a filename to be expanded."
(when (and (not eshell-current-argument)
+ (not eshell-current-quoted)
(eq (char-after) ?~))
;; Apply this modifier fairly early so it happens before things
;; like glob expansion.
diff --git a/test/lisp/eshell/em-dirs-tests.el
b/test/lisp/eshell/em-dirs-tests.el
index 2f170fb0c63..9789e519f4c 100644
--- a/test/lisp/eshell/em-dirs-tests.el
+++ b/test/lisp/eshell/em-dirs-tests.el
@@ -34,6 +34,9 @@
default-directory))))
;;; Tests:
+
+;; Variables
+
(ert-deftest em-dirs-test/pwd-var ()
"Test using the $PWD variable."
(let ((default-directory "/some/path"))
@@ -99,6 +102,25 @@
(eshell-match-command-output "echo $-[1][/ 1 3]"
"(\"some\" \"here\")\n"))))
+
+;; Argument expansion
+
+(ert-deftest em-dirs-test/expand-user-reference/local ()
+ "Test expansion of \"~USER\" references."
+ (eshell-command-result-equal "echo ~" (expand-file-name "~"))
+ (eshell-command-result-equal
+ (format "echo ~%s" user-login-name)
+ (expand-file-name (format "~%s" user-login-name))))
+
+(ert-deftest em-dirs-test/expand-user-reference/quoted ()
+ "Test that a quoted \"~\" isn't expanded."
+ (eshell-command-result-equal "echo \\~" "~")
+ (eshell-command-result-equal "echo \"~\"" "~")
+ (eshell-command-result-equal "echo '~'" "~"))
+
+
+;; `cd'
+
(ert-deftest em-dirs-test/cd ()
"Test that changing directories with `cd' works."
(ert-with-temp-directory tmpdir
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master d2abe91d4bf: In Eshell, don't expand quoted tildes into a user's home directory,
Jim Porter <=