* lisp/eshell/esh-util.el (eshell-get-path): Don't add "." if it
is already there.
* test/lisp/eshell/esh-var-tests.el
(esh-var-test/path-var/preserve-across-hosts): Skip on MS-Windows.
(esh-var-test/path-var/set, esh-var-test/path-var/set-locally):
Quote the PATH value, for MS-Windows.
* test/lisp/eshell/esh-util-tests.el (esh-util-test/path/get): No
need to add ".": it is already done by 'eshell-get-path'.
* test/lisp/eshell/esh-proc-tests.el
(esh-proc-test/kill-pipeline): Accept empty string as valid
output.
(esh-proc-test/sigpipe-exits-process): Skip on MS-Windows: no
SIGPIPE.
(esh-proc-test/emacs-command): Quote correctly for MS-Windows.
* test/lisp/eshell/em-unix-tests.el
(em-unix-test/compile/interactive): Fix test on MS-Windows.
* test/lisp/eshell/em-script-tests.el (em-script-test/batch-file):
Skip on MS-Windows.
* test/lisp/eshell/eshell-tests-helpers.el
(eshell-command-result--equal): Compare strings (file names)
case-insensitively on MS-Windows.
(cherry picked from commit
f869f1ffc2ef0e126e633553e6b4c38bee90f7f8)
(butlast (exec-path))))))
(when (and (not literal-p)
(not remote)
- (eshell-under-windows-p))
+ (eshell-under-windows-p)
+ (not (member "." path)))
(push "." path))
(if (and remote (not literal-p))
(mapcar (lambda (x) (concat remote x)) path)
(ert-deftest em-script-test/batch-file ()
"Test running an Eshell script file as a batch script."
+ (skip-unless (not (memq system-type '(windows-nt ms-dos))))
(ert-with-temp-file temp-file
:text (format
"#!/usr/bin/env -S %s --batch -f eshell-batch-file\necho hi"
"#<buffer \\*compilation\\*>")
(with-current-buffer "*compilation*"
(forward-line 3)
- (should (looking-at "echo hello")))))
+ (should (looking-at
+ ;; MS-Windows/DOS quote by unconditionally enclosing in
+ ;; double quotes.
+ (if (memq system-type '(windows-nt ms-dos))
+ "\"echo\" \"hello\""
+ "echo hello"))))))
(ert-deftest em-unix-test/compile/noninteractive ()
"Check that `eshell/compile' writes to stdout noninteractively."
"Test that a SIGPIPE is properly sent to a process if a pipe closes"
(skip-unless (and (executable-find "sh")
(executable-find "echo")
- (executable-find "sleep")))
+ (executable-find "sleep")
+ (not (eq system-type 'windows-nt))))
(let ((starting-process-list (process-list)))
(with-temp-eshell
(eshell-match-command-output
(defsubst esh-proc-test/emacs-command (command)
"Evaluate COMMAND in a new Emacs batch instance."
- (mapconcat #'shell-quote-argument
- `(,(expand-file-name invocation-name invocation-directory)
- "-Q" "--batch" "--eval" ,(prin1-to-string command))
- " "))
+ (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))
+ " ")))
(defvar esh-proc-test/emacs-echo
(esh-proc-test/emacs-command '(princ "hello\n"))
(eshell-wait-for-subprocess t)
(should (string-match-p
;; "interrupt\n" is for MS-Windows.
- (rx (or "interrupt\n" "killed\n" "killed: 9\n"))
+ (rx (or "interrupt\n" "killed\n" "killed: 9\n" ""))
(buffer-substring-no-properties
output-start (eshell-end-of-output)))))))
(ert-deftest esh-util-test/path/get ()
"Test that getting the Eshell path returns the expected results."
(let ((expected-path (butlast (exec-path))))
- (should (equal (eshell-get-path)
- (if (eshell-under-windows-p)
- (cons "." expected-path)
- expected-path)))
+ (should (equal (eshell-get-path) expected-path))
(should (equal (eshell-get-path 'literal)
expected-path))))
(let* ((path-to-set-list '("/some/path" "/other/path"))
(path-to-set (string-join path-to-set-list (path-separator))))
(with-temp-eshell
- (eshell-match-command-output (concat "set PATH " path-to-set)
+ ;; Quote PATH value, because on Windows path-separator is ';'.
+ (eshell-match-command-output (concat "set PATH \"" path-to-set "\"")
(concat path-to-set "\n"))
(eshell-match-command-output "echo $PATH" (concat path-to-set "\n"))
(should (equal (eshell-get-path t) path-to-set-list)))))
(let* ((path-to-set-list '("/some/path" "/other/path"))
(path-to-set (string-join path-to-set-list (path-separator))))
(with-temp-eshell
- (eshell-match-command-output (concat "set PATH " path-to-set)
+ (eshell-match-command-output (concat "set PATH \"" path-to-set "\"")
(concat path-to-set "\n"))
(eshell-match-command-output "PATH=/local/path env"
"PATH=/local/path\n")
(ert-deftest esh-var-test/path-var/preserve-across-hosts ()
"Test that $PATH can be set independently on multiple hosts."
+ (skip-unless (not (eq system-type 'windows-nt)))
(let ((local-directory default-directory)
local-path remote-path)
(with-temp-eshell
(defun eshell-command-result--equal (_command actual expected)
"Compare the ACTUAL result of a COMMAND with its EXPECTED value."
- (equal actual expected))
+ (or (equal actual expected)
+ ;; Compare case-isensitively on case-insensitive filesystems.
+ (and (memq system-type '(windows-nt ms-dos))
+ (stringp actual)
+ (stringp expected)
+ (string-equal-ignore-case actual expected))))
(defun eshell-command-result--equal-explainer (command actual expected)
"Explain the result of `eshell-command-result--equal'."