Fix listing of directory contents after "cd" in Eshell
* lisp/eshell/em-dirs.el (eshell/cd): Ensure we don't close the I/O handles prematurely. Additionally, don't clobber the "cd" command's last-command info. * test/lisp/eshell/em-dirs-tests.el (em-dirs-test/cd): (em-dirs-test/cd/list-files-after-cd): New tests (bug#65110).
This commit is contained in:
parent
b48793253b
commit
301e6a747a
2 changed files with 30 additions and 3 deletions
|
@ -429,9 +429,13 @@ in the minibuffer:
|
|||
(and eshell-cd-shows-directory
|
||||
(eshell-printn result)))
|
||||
(run-hooks 'eshell-directory-change-hook)
|
||||
(if eshell-list-files-after-cd
|
||||
;; Let-bind eshell-last-command around this?
|
||||
(eshell-plain-command "ls" (cdr args)))
|
||||
(when eshell-list-files-after-cd
|
||||
;; Call "ls", but don't update the last-command information.
|
||||
(let ((eshell-last-command-name)
|
||||
(eshell-last-command-status)
|
||||
(eshell-last-arguments))
|
||||
(eshell-protect
|
||||
(eshell-plain-command "ls" (cdr args)))))
|
||||
nil))))
|
||||
|
||||
(put 'eshell/cd 'eshell-no-numeric-conversions t)
|
||||
|
|
|
@ -99,4 +99,27 @@
|
|||
(eshell-match-command-output "echo $-[1][/ 1 3]"
|
||||
"(\"some\" \"here\")\n"))))
|
||||
|
||||
(ert-deftest em-dirs-test/cd ()
|
||||
"Test that changing directories with `cd' works."
|
||||
(ert-with-temp-directory tmpdir
|
||||
(write-region "text" nil (expand-file-name "file.txt" tmpdir))
|
||||
(with-temp-eshell
|
||||
(eshell-match-command-output (format "cd '%s'" tmpdir)
|
||||
"\\`\\'")
|
||||
(should (equal default-directory tmpdir)))))
|
||||
|
||||
(ert-deftest em-dirs-test/cd/list-files-after-cd ()
|
||||
"Test that listing files after `cd' works."
|
||||
(let ((eshell-list-files-after-cd t))
|
||||
(ert-with-temp-directory tmpdir
|
||||
(write-region "text" nil (expand-file-name "file.txt" tmpdir))
|
||||
(with-temp-eshell
|
||||
(eshell-match-command-output (format "cd '%s'" tmpdir)
|
||||
"file.txt\n")
|
||||
(should (equal default-directory tmpdir))
|
||||
;; Make sure we didn't update the last-command information when
|
||||
;; running "ls".
|
||||
(should (equal eshell-last-command-name "#<function eshell/cd>"))
|
||||
(should (equal eshell-last-arguments (list tmpdir)))))))
|
||||
|
||||
;; em-dirs-tests.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue