diff options
| author | Jim Porter | 2025-07-20 21:17:05 -0700 |
|---|---|---|
| committer | Jim Porter | 2025-07-21 18:47:43 -0700 |
| commit | dd29b0ab66d63b3b8e890c8de8f8e5c3fb44217a (patch) | |
| tree | 7b2357754197a368c5fb62c576581cc5bbf5f96b | |
| parent | cbfc095ed42be5fd2b848cb837b3340670fe9ef6 (diff) | |
| download | emacs-dd29b0ab66d63b3b8e890c8de8f8e5c3fb44217a.tar.gz emacs-dd29b0ab66d63b3b8e890c8de8f8e5c3fb44217a.zip | |
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).
| -rw-r--r-- | lisp/eshell/esh-io.el | 2 | ||||
| -rw-r--r-- | test/lisp/eshell/esh-io-tests.el | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index ff275560a04..1b474d988a7 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el | |||
| @@ -569,7 +569,7 @@ ends in a newline." | |||
| 569 | (eshell-output-object object handle) | 569 | (eshell-output-object object handle) |
| 570 | (when (and eshell-ensure-newline-p | 570 | (when (and eshell-ensure-newline-p |
| 571 | (not (and (stringp object) | 571 | (not (and (stringp object) |
| 572 | (string-suffix-p object "\n")))) | 572 | (string-suffix-p "\n" object)))) |
| 573 | (eshell-maybe-output-newline handle))) | 573 | (eshell-maybe-output-newline handle))) |
| 574 | 574 | ||
| 575 | (defsubst eshell-print-maybe-n (object) | 575 | (defsubst eshell-print-maybe-n (object) |
diff --git a/test/lisp/eshell/esh-io-tests.el b/test/lisp/eshell/esh-io-tests.el index 0b25ad812fa..e6bc5c9809c 100644 --- a/test/lisp/eshell/esh-io-tests.el +++ b/test/lisp/eshell/esh-io-tests.el | |||
| @@ -42,6 +42,28 @@ | |||
| 42 | ;;; Tests: | 42 | ;;; Tests: |
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | ;; Newlines | ||
| 46 | |||
| 47 | (ert-deftest esh-io-test/output-newline/add-newline () | ||
| 48 | "Ensure we add a newline when writing a string to stdout." | ||
| 49 | (with-temp-eshell | ||
| 50 | (eshell-match-command-output "(concat \"hello\")" "\\`hello\n\\'"))) | ||
| 51 | |||
| 52 | (ert-deftest esh-io-test/output-newline/no-newline () | ||
| 53 | "Ensure we don't add a newline when writing a string to a buffer." | ||
| 54 | (eshell-with-temp-buffer bufname "" | ||
| 55 | (with-temp-eshell | ||
| 56 | (eshell-match-command-output | ||
| 57 | (format "(concat \"hello\") > #<%s>" bufname) | ||
| 58 | "\\`\\'")) | ||
| 59 | (should (equal (buffer-string) "hello")))) | ||
| 60 | |||
| 61 | (ert-deftest esh-io-test/output-newline/no-extra-newline () | ||
| 62 | "Ensure we don't add an extra newline when writing to stdout." | ||
| 63 | (with-temp-eshell | ||
| 64 | (eshell-match-command-output "(concat \"hello\n\")" "\\`hello\n\\'"))) | ||
| 65 | |||
| 66 | |||
| 45 | ;; Basic redirection | 67 | ;; Basic redirection |
| 46 | 68 | ||
| 47 | (ert-deftest esh-io-test/redirect-file/overwrite () | 69 | (ert-deftest esh-io-test/redirect-file/overwrite () |