]> git.eshelyaron.com Git - emacs.git/commitdiff
Ensure 'eshell-output-object' always returns nil for consistency
authorJim Porter <jporterbugs@gmail.com>
Thu, 20 Jan 2022 05:57:38 +0000 (21:57 -0800)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 21 Feb 2022 17:39:40 +0000 (18:39 +0100)
This prevents functions like 'eshell-print' from writing doubled
output when run in Eshell.  Previously, the result would be:

  ~ $ eshell-print hi
  hihi

* lisp/eshell/esh-io.el (eshell-output-object): Always return nil.

lisp/eshell/esh-io.el

index e457f65c185b2d7ade0b0dfd85a46d7020c9fc1e..fc1124561a5637620f3d86f2da28df84fda9c20f 100644 (file)
@@ -491,14 +491,19 @@ Returns what was actually sent, or nil if nothing was sent."
   object)
 
 (defun eshell-output-object (object &optional handle-index handles)
-  "Insert OBJECT, using HANDLE-INDEX specifically)."
+  "Insert OBJECT, using HANDLE-INDEX specifically.
+If HANDLE-INDEX is nil, output to `eshell-output-handle'.
+HANDLES is the set of file handles to use; if nil, use
+`eshell-current-handles'."
   (let ((target (car (aref (or handles eshell-current-handles)
                           (or handle-index eshell-output-handle)))))
-    (if (and target (not (listp target)))
-       (eshell-output-object-to-target object target)
-      (while target
-       (eshell-output-object-to-target object (car target))
-       (setq target (cdr target))))))
+    (if (listp target)
+        (while target
+         (eshell-output-object-to-target object (car target))
+         (setq target (cdr target)))
+      (eshell-output-object-to-target object target)
+      ;; Explicitly return nil to match the list case above.
+      nil)))
 
 (provide 'esh-io)
 ;;; esh-io.el ends here