From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Matthew Leach Newsgroups: gmane.emacs.bugs 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 Message-ID: <87y2y5lfnb.fsf@1e0.co.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="248644"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: 37564@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 30 22:00:13 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iF1q8-0012Ss-Pc for geb-bug-gnu-emacs@m.gmane.org; Mon, 30 Sep 2019 22:00:12 +0200 Original-Received: from localhost ([::1]:56546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iF1q7-0005HE-JJ for geb-bug-gnu-emacs@m.gmane.org; Mon, 30 Sep 2019 16:00:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42171) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iF1q0-0005H3-3N for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2019 16:00:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iF1py-0002N2-Rl for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2019 16:00:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51714) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iF1py-0002MI-Nt for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2019 16:00:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iF1py-0004Zj-KO for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2019 16:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Matthew Leach Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Sep 2019 20:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 37564 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.156987355817496 (code B ref -1); Mon, 30 Sep 2019 20:00:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Sep 2019 19:59:18 +0000 Original-Received: from localhost ([127.0.0.1]:60535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iF1pF-0004Y7-QE for submit@debbugs.gnu.org; Mon, 30 Sep 2019 15:59:18 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:42093) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iF1pE-0004Xy-8Q for submit@debbugs.gnu.org; Mon, 30 Sep 2019 15:59:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42086) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iF1pC-0004zR-R4 for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2019 15:59:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iF1pA-0001ms-Df for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2019 15:59:13 -0400 Original-Received: from mx0.mattleach.net ([176.58.118.143]:60130) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iF1pA-0001lL-5p for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2019 15:59:12 -0400 Original-Received: by mx0.mattleach.net (Postfix, from userid 99) id 97FCE61C5D; Mon, 30 Sep 2019 20:59:07 +0100 (BST) Original-Received: from hopton.mattleach.net (92.40.249.172.threembb.co.uk [92.40.249.172]) by mx0.mattleach.net (Postfix) with ESMTPSA id 3111961C21 for ; Mon, 30 Sep 2019 20:59:06 +0100 (BST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:167945 Archived-At: --=-=-= Content-Type: text/plain 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 (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) --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-don-t-export-LINES-and-COLUMNS-env-vars-to-term.patch >From 20b1adff1c32cfeeba1cf3101b05d5c76037206d Mon Sep 17 00:00:00 2001 From: Matthew Leach 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 --=-=-= Content-Type: text/plain -- Matt --=-=-=--