GNU bug report logs -
#37564
[PATCH] don't export LINES and COLUMNS env vars in term to fix ncurses applications
Previous Next
Reported by: Matthew Leach <matthew <at> mattleach.net>
Date: Mon, 30 Sep 2019 20:00:02 UTC
Severity: normal
Tags: fixed, patch
Merged with 11432
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
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)
[0001-don-t-export-LINES-and-COLUMNS-env-vars-to-term.patch (text/x-patch, inline)]
From 20b1adff1c32cfeeba1cf3101b05d5c76037206d Mon Sep 17 00:00:00 2001
From: Matthew Leach <matthew <at> 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
[Message part 3 (text/plain, inline)]
--
Matt
This bug report was last modified 4 years and 269 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.