emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 63d084d4e4: Fix encoding and decoding of process I/O in Eshell on


From: Eli Zaretskii
Subject: master 63d084d4e4: Fix encoding and decoding of process I/O in Eshell on Windows
Date: Sat, 15 Oct 2022 07:01:02 -0400 (EDT)

branch: master
commit 63d084d4e435ae80e41ed19cfc48658819f84477
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix encoding and decoding of process I/O in Eshell on Windows
    
    * lisp/eshell/esh-proc.el (eshell-gather-process-output): Set up
    encoding and decoding of text to/from the subprocess for
    MS-Windows.  (Bug#58281)
---
 lisp/eshell/esh-proc.el | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index 7e005a0fc1..bb928fc5fb 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -277,7 +277,23 @@ Used only on systems which do not support async 
subprocesses.")
              eshell-delete-exited-processes
            delete-exited-processes))
         (process-environment (eshell-environment-variables))
+         (coding-system-for-read coding-system-for-read)
+         (coding-system-for-write coding-system-for-write)
         proc stderr-proc decoding encoding changed)
+    ;; MS-Windows needs special setting of encoding/decoding, because
+    ;; (a) non-ASCII text in command-line arguments needs to be
+    ;; encoded in the system's codepage; and (b) because many Windows
+    ;; programs will always interpret any non-ASCII input as encoded
+    ;; in the system codepage.
+    (when (eq system-type 'windows-nt)
+      (or coding-system-for-read        ; Honor manual decoding settings
+          (setq coding-system-for-read
+                (coding-system-change-eol-conversion locale-coding-system
+                                                     'dos)))
+      (or coding-system-for-write       ; Honor manual encoding settings
+          (setq coding-system-for-write
+                (coding-system-change-eol-conversion locale-coding-system
+                                                     'unix))))
     (cond
      ((fboundp 'make-process)
       (unless (equal (car (aref eshell-current-handles eshell-output-handle))
@@ -325,7 +341,7 @@ Used only on systems which do not support async 
subprocesses.")
            (setq decoding (coding-system-change-eol-conversion decoding 'dos)
                  changed t))
        ;; Even if `make-process' left the coding system for encoding
-       ;; data sent from the process undecided, we had better use the
+       ;; data sent to the process undecided, we had better use the
        ;; same one as what we use for decoding.  But, we should
        ;; suppress EOL conversion.
        (if (and decoding (not encoding))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]