GNU bug report logs - #48375
coding-system-for-read in net-utils-run-simple is not properly set

Previous Next

Package: emacs;

Reported by: iquiw <iku.iwasa <at> gmail.com>

Date: Wed, 12 May 2021 09:40:01 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 48375 in the body.
You can then email your comments to 48375 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#48375; Package emacs. (Wed, 12 May 2021 09:40:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to iquiw <iku.iwasa <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 12 May 2021 09:40:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: iquiw <iku.iwasa <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: coding-system-for-read in net-utils-run-simple is not properly set
Date: Wed, 12 May 2021 18:39:25 +0900
In the following code, `let' binding of `coding-system-for-read'
covers only `erase-buffer' call.

https://emba.gnu.org/emacs/emacs/-/blob/47070ed39eda524d334e5f82dc7f4a50b8d3252c/lisp/net/net-utils.el#L366-375

So it does not affect to executed process and output characters are garbled.
e.g. "M-x ifconfig" on Windows.

`net-utils-run-program' (e.g. "M-x ping") has no problem.

Thanks in advance,
Iku




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48375; Package emacs. (Sat, 15 May 2021 08:27:01 GMT) Full text and rfc822 format available.

Message #8 received at 48375 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: iquiw <iku.iwasa <at> gmail.com>
Cc: 48375 <at> debbugs.gnu.org
Subject: Re: bug#48375: coding-system-for-read in net-utils-run-simple is not
 properly set
Date: Sat, 15 May 2021 11:26:32 +0300
> From: iquiw <iku.iwasa <at> gmail.com>
> Date: Wed, 12 May 2021 18:39:25 +0900
> 
> In the following code, `let' binding of `coding-system-for-read'
> covers only `erase-buffer' call.
> 
> https://emba.gnu.org/emacs/emacs/-/blob/47070ed39eda524d334e5f82dc7f4a50b8d3252c/lisp/net/net-utils.el#L366-375
> 
> So it does not affect to executed process and output characters are garbled.
> e.g. "M-x ifconfig" on Windows.

Thanks.  Does the patch below fix the problem?

diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
index 24f2aba..90cca7d 100644
--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -363,24 +363,24 @@ net-utils-run-simple
       (when proc
         (set-process-filter proc nil)
         (delete-process proc)))
-    (let ((inhibit-read-only t)
-	(coding-system-for-read
-	 ;; MS-Windows versions of network utilities output text
-	 ;; encoded in the console (a.k.a. "OEM") codepage, which is
-	 ;; different from the default system (a.k.a. "ANSI")
-	 ;; codepage.
-	 (if (eq system-type 'windows-nt)
-	     (intern (format "cp%d" (w32-get-console-output-codepage)))
-	   coding-system-for-read)))
+    (let ((inhibit-read-only t))
       (erase-buffer))
     (net-utils-mode)
     (setq-local net-utils--revert-cmd
                 `(net-utils-run-simple ,(current-buffer)
                                        ,program-name ,args nodisplay))
-    (set-process-filter
-     (apply #'start-process program-name
-            (current-buffer) program-name args)
-     #'net-utils-remove-ctrl-m-filter)
+    (let ((coding-system-for-read
+	   ;; MS-Windows versions of network utilities output text
+	   ;; encoded in the console (a.k.a. "OEM") codepage, which is
+	   ;; different from the default system (a.k.a. "ANSI")
+	   ;; codepage.
+	   (if (eq system-type 'windows-nt)
+	       (intern (format "cp%d" (w32-get-console-output-codepage)))
+	     coding-system-for-read)))
+      (set-process-filter
+       (apply #'start-process program-name
+              (current-buffer) program-name args)
+       #'net-utils-remove-ctrl-m-filter))
     (unless nodisplay (display-buffer (current-buffer)))))
 
 (defun net-utils--revert-function (&optional _ignore-auto _noconfirm)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#48375; Package emacs. (Sat, 15 May 2021 09:33:01 GMT) Full text and rfc822 format available.

Message #11 received at 48375 <at> debbugs.gnu.org (full text, mbox):

From: iquiw <iku.iwasa <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 48375 <at> debbugs.gnu.org
Subject: Re: bug#48375: coding-system-for-read in net-utils-run-simple is not
 properly set
Date: Sat, 15 May 2021 18:32:05 +0900
On Sat, May 15, 2021 at 5:26 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > From: iquiw <iku.iwasa <at> gmail.com>
> > Date: Wed, 12 May 2021 18:39:25 +0900
> >
> > In the following code, `let' binding of `coding-system-for-read'
> > covers only `erase-buffer' call.
> >
> > https://emba.gnu.org/emacs/emacs/-/blob/47070ed39eda524d334e5f82dc7f4a50b8d3252c/lisp/net/net-utils.el#L366-375
> >
> > So it does not affect to executed process and output characters are garbled.
> > e.g. "M-x ifconfig" on Windows.
>
> Thanks.  Does the patch below fix the problem?

Yes, it works fine with the patch.
Thank you!




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 15 May 2021 09:40:02 GMT) Full text and rfc822 format available.

Notification sent to iquiw <iku.iwasa <at> gmail.com>:
bug acknowledged by developer. (Sat, 15 May 2021 09:40:02 GMT) Full text and rfc822 format available.

Message #16 received at 48375-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: iquiw <iku.iwasa <at> gmail.com>
Cc: 48375-done <at> debbugs.gnu.org
Subject: Re: bug#48375: coding-system-for-read in net-utils-run-simple is not
 properly set
Date: Sat, 15 May 2021 12:39:25 +0300
> From: iquiw <iku.iwasa <at> gmail.com>
> Date: Sat, 15 May 2021 18:32:05 +0900
> Cc: 48375 <at> debbugs.gnu.org
> 
> > > In the following code, `let' binding of `coding-system-for-read'
> > > covers only `erase-buffer' call.
> > >
> > > https://emba.gnu.org/emacs/emacs/-/blob/47070ed39eda524d334e5f82dc7f4a50b8d3252c/lisp/net/net-utils.el#L366-375
> > >
> > > So it does not affect to executed process and output characters are garbled.
> > > e.g. "M-x ifconfig" on Windows.
> >
> > Thanks.  Does the patch below fix the problem?
> 
> Yes, it works fine with the patch.
> Thank you!

Thanks for testing, I installed the fix on the master branch, and I'm
closing this bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 12 Jun 2021 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 2 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.