unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#37564: [PATCH] don't export LINES and COLUMNS env vars in term to fix ncurses applications
@ 2019-09-30 19:59 Matthew Leach
  2019-10-01  6:01 ` Eli Zaretskii
  0 siblings, 1 reply; 26+ messages in thread
From: Matthew Leach @ 2019-09-30 19:59 UTC (permalink / raw)
  To: 37564

[-- Attachment #1: Type: text/plain, Size: 1189 bytes --]

Hi all,

The attached patch removes the exporting of the LINES and COLUMNS
environment variables in term-mode.  Exporting these variables causes
issues for ncurses applications.  For example, when running:

emacs -Q
M-x term
<ret> (to select /bin/bash)
htop (to run htop)

and resizing the window (especially making it smaller) can make the
program impossible to read.

The ncurses code uses an ioctl() initially to get the current size[1]
which returns a correct result. However, since we exported the above
environment variables these values are discarded in favour of the (now
stale) values of LINES and COLUMNS. Emacs makes no attempt to update
these variables when the window is resized. Therefore, ncurses assumes
the window size is the same when it has actually changed.

Note that executing:

$ echo $LINES

from a bash shell actually doesn't get the LINES environment variable as
can be seen with:

$ printenv | grep LINES

Whenever $LINES is accessed, bash translates this into an ioctl() and
returns the result. Therefore, removing these variables shouldn't
prevent any shell scripts from accessing these variables.

[1]: ncurses/ncurses/tinfo/lib_setup.c (_nc_get_screensize)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-don-t-export-LINES-and-COLUMNS-env-vars-to-term.patch --]
[-- Type: text/x-patch, Size: 1015 bytes --]

From 20b1adff1c32cfeeba1cf3101b05d5c76037206d Mon Sep 17 00:00:00 2001
From: Matthew Leach <matthew@mattleach.net>
Date: Mon, 30 Sep 2019 20:35:54 +0100
Subject: [PATCH] don't export LINES and COLUMNS env vars to term

* lisp/term.el (term-exec-1): Remove the exporting of the LINES and
COLUMNS environment variables to the terminal process.
---
 lisp/term.el | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lisp/term.el b/lisp/term.el
index 66ae470239a..e309bd802d5 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -1550,9 +1550,7 @@ term-exec-1
 	   (format term-termcap-format "TERMCAP="
 		   term-term-name term-height term-width)
 
-	   (format "INSIDE_EMACS=%s,term:%s" emacs-version term-protocol-version)
-	   (format "LINES=%d" term-height)
-	   (format "COLUMNS=%d" term-width))
+	   (format "INSIDE_EMACS=%s,term:%s" emacs-version term-protocol-version))
 	  process-environment))
 	(process-connection-type t)
 	;; We should suppress conversion of end-of-line format.
-- 
2.23.0


[-- Attachment #3: Type: text/plain, Size: 9 bytes --]

-- 
Matt

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2020-08-15 12:37 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-30 19:59 bug#37564: [PATCH] don't export LINES and COLUMNS env vars in term to fix ncurses applications Matthew Leach
2019-10-01  6:01 ` Eli Zaretskii
2019-10-01 15:47   ` Matthew Leach
2019-10-01 16:07     ` Eli Zaretskii
2019-10-01 18:33       ` Matthew Leach
2019-10-01 18:58         ` Eli Zaretskii
2019-10-01 19:14           ` Eli Zaretskii
2019-10-01 19:24           ` Matthew Leach
2019-10-02  2:28             ` Eli Zaretskii
2019-10-03 17:51               ` Glenn Morris
2019-10-04 18:48                 ` Matthew Leach
2020-01-20 19:10                   ` Stefan Kangas
2020-01-20 19:30                     ` Eli Zaretskii
2020-01-21  0:58                       ` Glenn Morris
2020-01-21 17:11                         ` Eli Zaretskii
2020-01-21 18:10                           ` Matthew Leach
2020-01-22  3:38                         ` Glenn Morris
2020-01-22 15:46                           ` Eli Zaretskii
2020-06-04 16:01                             ` Glenn Morris
2020-08-15 12:37                             ` Lars Ingebrigtsen
2020-01-24 18:08                           ` Stefan Kangas
2020-01-21  3:04                       ` Stefan Kangas
2019-10-04 18:47               ` Matthew Leach
2019-10-07  4:11             ` Lars Ingebrigtsen
2019-10-07  9:16               ` Andreas Schwab
2019-10-08 16:38                 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).