mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Fix Eshell call to 'string-suffix-p' when checking for trailing newline
* lisp/eshell/esh-io.el (eshell--output-maybe-n): Fix call. * test/lisp/eshell/esh-io-tests.el (esh-io-test/output-newline/add-newline) (esh-io-test/output-newline/no-newline) (esh-io-test/output-newline/no-extra-newline): New tests (bug#79063).
This commit is contained in:
parent
cbfc095ed4
commit
dd29b0ab66
2 changed files with 23 additions and 1 deletions
|
|
@ -569,7 +569,7 @@ ends in a newline."
|
|||
(eshell-output-object object handle)
|
||||
(when (and eshell-ensure-newline-p
|
||||
(not (and (stringp object)
|
||||
(string-suffix-p object "\n"))))
|
||||
(string-suffix-p "\n" object))))
|
||||
(eshell-maybe-output-newline handle)))
|
||||
|
||||
(defsubst eshell-print-maybe-n (object)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,28 @@
|
|||
|
||||
;;; Tests:
|
||||
|
||||
|
||||
;; Newlines
|
||||
|
||||
(ert-deftest esh-io-test/output-newline/add-newline ()
|
||||
"Ensure we add a newline when writing a string to stdout."
|
||||
(with-temp-eshell
|
||||
(eshell-match-command-output "(concat \"hello\")" "\\`hello\n\\'")))
|
||||
|
||||
(ert-deftest esh-io-test/output-newline/no-newline ()
|
||||
"Ensure we don't add a newline when writing a string to a buffer."
|
||||
(eshell-with-temp-buffer bufname ""
|
||||
(with-temp-eshell
|
||||
(eshell-match-command-output
|
||||
(format "(concat \"hello\") > #<%s>" bufname)
|
||||
"\\`\\'"))
|
||||
(should (equal (buffer-string) "hello"))))
|
||||
|
||||
(ert-deftest esh-io-test/output-newline/no-extra-newline ()
|
||||
"Ensure we don't add an extra newline when writing to stdout."
|
||||
(with-temp-eshell
|
||||
(eshell-match-command-output "(concat \"hello\n\")" "\\`hello\n\\'")))
|
||||
|
||||
|
||||
;; Basic redirection
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue