;; command status to some non-zero value to indicate an error; to
;; match GNU/Linux, we use 141, which the numeric value of
;; SIGPIPE on GNU/Linux (13) with the high bit (2^7) set.
- (eshell-set-exit-info 141)
+ (when (memq eshell-in-pipeline-p '(nil last))
+ (eshell-set-exit-info 141))
nil)
(error
- (eshell-set-exit-info 1)
+ (when (memq eshell-in-pipeline-p '(nil last))
+ (eshell-set-exit-info 1))
(let ((msg (error-message-string err)))
(if (and (not form-p)
(string-match "^Wrong number of arguments" msg)
(unless eshell-allow-commands
(signal 'eshell-commands-forbidden '(lisp)))
(catch 'eshell-external ; deferred to an external command
- (eshell-set-exit-info 0)
+ (when (memq eshell-in-pipeline-p '(nil last))
+ (eshell-set-exit-info 0))
(setq eshell-last-arguments args)
(let* ((eshell-ensure-newline-p t)
(command-form-p (functionp object))
(eshell-eval* #'eshell-print-maybe-n
#'eshell-error-maybe-n
object))))
- (eshell-set-exit-info
- ;; If `eshell-lisp-form-nil-is-failure' is non-nil, Lisp forms
- ;; that succeeded but have a nil result should have an exit
- ;; status of 2.
- (when (and eshell-lisp-form-nil-is-failure
- (not command-form-p)
- (= eshell-last-command-status 0)
- (not result))
- 2)
- result)
+ (when (memq eshell-in-pipeline-p '(nil last))
+ (eshell-set-exit-info
+ ;; If `eshell-lisp-form-nil-is-failure' is non-nil, Lisp forms
+ ;; that succeeded but have a nil result should have an exit
+ ;; status of 2.
+ (when (and eshell-lisp-form-nil-is-failure
+ (not command-form-p)
+ (= eshell-last-command-status 0)
+ (not result))
+ 2)
+ result))
(eshell-close-handles))))
(define-obsolete-function-alias 'eshell-lisp-command* #'eshell-lisp-command
(mapconcat #'shell-quote-argument (process-command proc) " "))
(eshell-record-process-object proc)
(eshell-record-process-properties proc)
+ ;; Don't set exit info for processes being piped elsewhere.
+ (when (memq (bound-and-true-p eshell-in-pipeline-p) '(nil last))
+ (process-put proc :eshell-set-exit-info t))
(when stderr-proc
;; Provide a shared flag between the primary and stderr
;; processes. This lets the primary process wait to clean up
(let* ((handles (process-get proc :eshell-handles))
(index (process-get proc :eshell-handle-index))
(primary (= index eshell-output-handle))
+ (set-exit-info (process-get proc :eshell-set-exit-info))
(data (process-get proc :eshell-pending))
(stderr-live (process-get proc :eshell-stderr-live)))
;; Write the exit message for the last process in the
(ignore-error eshell-pipe-broken
(eshell-output-object
data index handles)))
- (when primary
+ (when set-exit-info
(let ((status (process-exit-status proc)))
(eshell-set-exit-info status (= status 0))))
(eshell-close-handles handles)
"sh -c 'read NAME; echo ${NAME}'")
"y\n")
(eshell-wait-for-subprocess t)
- (should (equal (process-list) starting-process-list)))))
+ (should (equal (process-list) starting-process-list))
+ ;; Make sure the exit status is from the last command in the
+ ;; pipeline.
+ (should (= eshell-last-command-status 0)))))
(ert-deftest esh-proc-test/pipeline-connection-type/no-pipeline ()
"Test that all streams are PTYs when a command is not in a pipeline."