]> git.eshelyaron.com Git - emacs.git/commitdiff
A better fix for esh-proc-tests on MS-Windows
authorEli Zaretskii <eliz@gnu.org>
Sun, 9 Jun 2024 13:12:11 +0000 (16:12 +0300)
committerEshel Yaron <me@eshelyaron.com>
Mon, 10 Jun 2024 07:26:10 +0000 (09:26 +0200)
* test/lisp/eshell/esh-proc-tests.el
(esh-proc-test-quote-argument): New function.
(esh-proc-test/emacs-command): Use it instead of
'shell-quote-argument', which allows to go back to
system-independent code.

(cherry picked from commit 5c8a8b7dd32d956abffbab501ea9316e2d4a57d1)

test/lisp/eshell/esh-proc-tests.el

index cf869edbe0c6048dbb2c2d834cd7138e57207065..c1e8800f706cbd0c5cfcd7760d76c9a8c773ae44 100644 (file)
@@ -196,22 +196,18 @@ pipeline."
 ;; against; that way, users don't need to have GNU coreutils (or
 ;; similar) installed.
 
+;; This is needed because system shell quoting semantics is not relevant
+;; when Eshell is the shell.
+(defun esh-proc-test-quote-argument (argument)
+  "Quote ARGUMENT using Posix semantics."
+  (shell-quote-argument argument t))
+
 (defsubst esh-proc-test/emacs-command (command)
   "Evaluate COMMAND in a new Emacs batch instance."
-  (if (eq system-type 'windows-nt)
-      ;; The MS-Windows implementation of shell-quote-argument is too
-      ;; much for arguments that already have quotes, so we quote "by
-      ;; hand" here.
-      (concat (shell-quote-argument
-               (expand-file-name invocation-name invocation-directory))
-              " -Q --batch --eval "
-              "\""
-              (string-replace "\"" "\\\"" (prin1-to-string command))
-              "\"")
-    (mapconcat #'shell-quote-argument
-               `(,(expand-file-name invocation-name invocation-directory)
-                 "-Q" "--batch" "--eval" ,(prin1-to-string command))
-               " ")))
+  (mapconcat #'esh-proc-test-quote-argument
+             `(,(expand-file-name invocation-name invocation-directory)
+               "-Q" "--batch" "--eval" ,(prin1-to-string command))
+             " "))
 
 (defvar esh-proc-test/emacs-echo
   (esh-proc-test/emacs-command '(princ "hello\n"))