changeset 99825:b49dc2c06161

(eshell-gather-process-output): Set process-connection-type nil for all but the first element of a pipeline. (Bug#1388)
author Glenn Morris <rgm@gnu.org>
date Sun, 23 Nov 2008 03:05:29 +0000
parents df01f003c105
children 90472c8328f5
files lisp/eshell/esh-proc.el
diffstat 1 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/eshell/esh-proc.el	Sun Nov 23 03:02:48 2008 +0000
+++ b/lisp/eshell/esh-proc.el	Sun Nov 23 03:05:29 2008 +0000
@@ -250,11 +250,27 @@
     (cond
      ((fboundp 'start-process)
       (setq proc
-	    (apply 'start-process
-		   (file-name-nondirectory command) nil
-		   ;; `start-process' can't deal with relative
-		   ;; filenames
-		   (append (list (expand-file-name command)) args)))
+	    ;; Bug#1388.  Some commands (eg bc) check isatty to decide
+	    ;; whether they are being called interactively.
+	    ;; A normal shell pipeline has:
+	    ;; first: stdin tty , stdout pipe
+	    ;; rest : stdin pipe, stdout pipe
+	    ;; last : stdin pipe, stdout tty
+	    ;; We have:
+	    ;; first: stdin tty , stdout tty
+	    ;; last : stdin pipe, stdout pipe
+	    ;; In other words, the first and last elements have the
+	    ;; wrong kind of stdout.  (Perhaps this does not matter much...)
+	    ;; FIXME which is better for the first element:
+	    ;; tty/tty (as now), or pipe/pipe?
+	    (let ((process-connection-type
+		   (unless (and eshell-in-pipeline-p
+				(not (eq eshell-in-pipeline-p 'first)))
+		     process-connection-type)))
+	      (apply 'start-process
+		     (file-name-nondirectory command) nil
+		     ;; `start-process' can't deal with relative filenames
+		     (append (list (expand-file-name command)) args))))
       (eshell-record-process-object proc)
       (set-process-buffer proc (current-buffer))
       (if (eshell-interactive-output-p)