unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Matthew Leach <matthew@mattleach.net>
To: 37564@debbugs.gnu.org
Subject: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in term to fix ncurses applications
Date: Mon, 30 Sep 2019 20:59:04 +0100	[thread overview]
Message-ID: <87y2y5lfnb.fsf@1e0.co.uk> (raw)

[-- 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

             reply	other threads:[~2019-09-30 19:59 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-30 19:59 Matthew Leach [this message]
2019-10-01  6:01 ` bug#37564: [PATCH] don't export LINES and COLUMNS env vars in term to fix ncurses applications 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y2y5lfnb.fsf@1e0.co.uk \
    --to=matthew@mattleach.net \
    --cc=37564@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).