diff --git a/lisp/eshell/em-glob.el b/lisp/eshell/em-glob.el index 8c8466960c1..57bb0c53b57 100644 --- a/lisp/eshell/em-glob.el +++ b/lisp/eshell/em-glob.el @@ -141,7 +141,7 @@ This mimics the behavior of zsh if non-nil, but bash if nil." (when (boundp 'eshell-special-chars-outside-quoting) (setq-local eshell-special-chars-outside-quoting (append eshell-glob-chars-list eshell-special-chars-outside-quoting))) - (add-hook 'eshell-parse-argument-hook 'eshell-parse-glob-chars t t) + (add-hook 'eshell-parse-argument-hook 'eshell-parse-glob-chars 90 t) (add-hook 'eshell-pre-rewrite-command-hook 'eshell-no-command-globbing nil t)) @@ -165,22 +165,7 @@ The character is not advanced for ordinary globbing characters, so that other function may have a chance to override the globbing interpretation." (when (memq (char-after) eshell-glob-chars-list) - (if (not (memq (char-after) '(?\( ?\[))) - (ignore (eshell-add-glob-modifier)) - (let ((here (point))) - (forward-char) - (let* ((delim (char-before)) - (end (eshell-find-delimiter - delim (if (eq delim ?\[) ?\] ?\))))) - (if (not end) - (throw 'eshell-incomplete (char-to-string delim)) - (if (and (eshell-using-module 'eshell-pred) - (eshell-arg-delimiter (1+ end))) - (ignore (goto-char here)) - (eshell-add-glob-modifier) - (prog1 - (buffer-substring-no-properties (1- (point)) (1+ end)) - (goto-char (1+ end)))))))))) + (ignore (eshell-add-glob-modifier)))) (defvar eshell-glob-matches) (defvar message-shown) diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el index 053ebf91dab..df7438ffa4d 100644 --- a/lisp/eshell/em-pred.el +++ b/lisp/eshell/em-pred.el @@ -261,8 +261,8 @@ respectively.") (defun eshell-pred-initialize () ;Called from `eshell-mode' via intern-soft! "Initialize the predicate/modifier code." - (add-hook 'eshell-parse-argument-hook - #'eshell-parse-arg-modifier t t) + ;; Make sure this function runs before `eshell-parse-glob-chars'. + (add-hook 'eshell-parse-argument-hook #'eshell-parse-arg-modifier 50 t) (eshell-pred-mode)) (defun eshell-apply-modifiers (lst predicates modifiers string-desc) diff --git a/test/lisp/eshell/em-glob-tests.el b/test/lisp/eshell/em-glob-tests.el index 88e9cc73bbd..239968917ab 100644 --- a/test/lisp/eshell/em-glob-tests.el +++ b/test/lisp/eshell/em-glob-tests.el @@ -317,4 +317,15 @@ value of `eshell-glob-splice-results'." (should (equal (eshell-extended-glob (format "%s~/file.txt" remote)) (format "%s~/file.txt" remote))))) +;; Compatibility tests + + +(ert-deftest em-glob-test/test-command-without-pred () + "Test that the \"[\" command works when `eshell-pred' is disabled." + (skip-unless (executable-find "[")) + (let ((eshell-modules-list (remq 'eshell-pred eshell-modules-list))) + (with-temp-eshell + (eshell-match-command-output "[ foo = foo ]" "\\`\\'") + (should (= eshell-last-command-status 0))))) + ;; em-glob-tests.el ends here