GNU bug report logs - #37564
[PATCH] don't export LINES and COLUMNS env vars in term to fix ncurses applications

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Matthew Leach <matthew@HIDDEN>; Keywords: patch; dated Mon, 30 Sep 2019 20:00:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 8 Oct 2019 16:38:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 08 12:38:39 2019
Received: from localhost ([127.0.0.1]:51352 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iHsVT-00071b-0g
	for submit <at> debbugs.gnu.org; Tue, 08 Oct 2019 12:38:39 -0400
Received: from quimby.gnus.org ([80.91.231.51]:39682)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1iHsVQ-00071R-G8
 for 37564 <at> debbugs.gnu.org; Tue, 08 Oct 2019 12:38:37 -0400
Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie)
 by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.89) (envelope-from <larsi@HIDDEN>)
 id 1iHsVM-0007Rw-Jp; Tue, 08 Oct 2019 18:38:35 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Andreas Schwab <schwab@HIDDEN>
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
References: <87y2y5lfnb.fsf@HIDDEN> <83eezxatsv.fsf@HIDDEN>
 <87tv8slb6w.fsf@HIDDEN> <83a7aka1q5.fsf@HIDDEN>
 <87sgocfh8c.fsf@HIDDEN> <83y2y48f8u.fsf@HIDDEN>
 <87o8z0few1.fsf@HIDDEN> <87sgo59oug.fsf@HIDDEN>
 <878spw3ogl.fsf@HIDDEN>
Date: Tue, 08 Oct 2019 18:38:32 +0200
In-Reply-To: <878spw3ogl.fsf@HIDDEN> (Andreas Schwab's message of "Mon, 07
 Oct 2019 11:16:26 +0200")
Message-ID: <87muebyyyf.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Andreas Schwab <schwab@HIDDEN> writes: > `set'
 doesn't print the environment,
 it prints the shell variables. To > print the environment, 
 use `export -p' or `printenv'. I see. Yes, they are not in my environment
 when I check with printenv. 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 37564
Cc: Matthew Leach <matthew@HIDDEN>, 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Andreas Schwab <schwab@HIDDEN> writes:

> `set' doesn't print the environment, it prints the shell variables.  To
> print the environment, use `export -p' or `printenv'.

I see.  Yes, they are not in my environment when I check with printenv.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 7 Oct 2019 09:16:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 07 05:16:33 2019
Received: from localhost ([127.0.0.1]:47366 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iHP84-0000pl-QP
	for submit <at> debbugs.gnu.org; Mon, 07 Oct 2019 05:16:33 -0400
Received: from mail-out.m-online.net ([212.18.0.9]:46747)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <whitebox@HIDDEN>) id 1iHP81-0000pb-5N
 for 37564 <at> debbugs.gnu.org; Mon, 07 Oct 2019 05:16:31 -0400
Received: from frontend01.mail.m-online.net (unknown [192.168.8.182])
 by mail-out.m-online.net (Postfix) with ESMTP id 46mvx8030Tz1rKJk;
 Mon,  7 Oct 2019 11:16:27 +0200 (CEST)
Received: from localhost (dynscan1.mnet-online.de [192.168.6.70])
 by mail.m-online.net (Postfix) with ESMTP id 46mvx75Qnmz1qqkC;
 Mon,  7 Oct 2019 11:16:27 +0200 (CEST)
X-Virus-Scanned: amavisd-new at mnet-online.de
Received: from mail.mnet-online.de ([192.168.8.182])
 by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new,
 port 10024)
 with ESMTP id 4sNlZhyFVHbw; Mon,  7 Oct 2019 11:16:27 +0200 (CEST)
X-Auth-Info: TpsNO53QkHkWaC84RHJ9cJe5ljNgJdciMOFyMzNyAEqPbxcjbsV8dzKmlMr3czMW
Received: from igel.home (ppp-46-244-165-160.dynamic.mnet-online.de
 [46.244.165.160])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mail.mnet-online.de (Postfix) with ESMTPSA;
 Mon,  7 Oct 2019 11:16:26 +0200 (CEST)
Received: by igel.home (Postfix, from userid 1000)
 id 420FB2C0181; Mon,  7 Oct 2019 11:16:26 +0200 (CEST)
From: Andreas Schwab <schwab@HIDDEN>
To: Lars Ingebrigtsen <larsi@HIDDEN>
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
References: <87y2y5lfnb.fsf@HIDDEN> <83eezxatsv.fsf@HIDDEN>
 <87tv8slb6w.fsf@HIDDEN> <83a7aka1q5.fsf@HIDDEN>
 <87sgocfh8c.fsf@HIDDEN> <83y2y48f8u.fsf@HIDDEN>
 <87o8z0few1.fsf@HIDDEN> <87sgo59oug.fsf@HIDDEN>
X-Yow: I'm GLAD I remembered to XEROX all my UNDERSHIRTS!!
Date: Mon, 07 Oct 2019 11:16:26 +0200
In-Reply-To: <87sgo59oug.fsf@HIDDEN> (Lars Ingebrigtsen's message of "Mon,
 07 Oct 2019 06:11:35 +0200")
Message-ID: <878spw3ogl.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.5 (/)
X-Debbugs-Envelope-To: 37564
Cc: Matthew Leach <matthew@HIDDEN>, 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.5 (-)

On Okt 07 2019, Lars Ingebrigtsen <larsi@HIDDEN> wrote:

> I tried this in my bash here (under the "Terminal" program in Debian):
>
> larsi@marnie:~/src/emacs/trunk$ set | grep LINES
> LINES=24
> larsi@marnie:~/src/emacs/trunk$ set | grep COLUMNS
> COLUMNS=80
>
> So they're in my env at least.

`set' doesn't print the environment, it prints the shell variables.  To
print the environment, use `export -p' or `printenv'.

Andreas.

-- 
Andreas Schwab, schwab@HIDDEN
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 7 Oct 2019 04:11:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 07 00:11:41 2019
Received: from localhost ([127.0.0.1]:47155 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iHKN3-00042O-AZ
	for submit <at> debbugs.gnu.org; Mon, 07 Oct 2019 00:11:41 -0400
Received: from quimby.gnus.org ([80.91.231.51]:55586)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1iHKN1-00042E-3b
 for 37564 <at> debbugs.gnu.org; Mon, 07 Oct 2019 00:11:40 -0400
Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie)
 by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.89) (envelope-from <larsi@HIDDEN>)
 id 1iHKMx-0005V0-D6; Mon, 07 Oct 2019 06:11:37 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Matthew Leach <matthew@HIDDEN>
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
References: <87y2y5lfnb.fsf@HIDDEN> <83eezxatsv.fsf@HIDDEN>
 <87tv8slb6w.fsf@HIDDEN> <83a7aka1q5.fsf@HIDDEN>
 <87sgocfh8c.fsf@HIDDEN> <83y2y48f8u.fsf@HIDDEN>
 <87o8z0few1.fsf@HIDDEN>
Date: Mon, 07 Oct 2019 06:11:35 +0200
In-Reply-To: <87o8z0few1.fsf@HIDDEN> (Matthew Leach's message of "Tue, 
 01 Oct 2019 20:24:14 +0100")
Message-ID: <87sgo59oug.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  Matthew Leach <matthew@HIDDEN> writes: >> I simply
 tried "env | fgrep LINES" and I do see the variable, although >> it wasn't
 there before I launched Emacs. > > I would expect the variable to be there
 when inside Emacs as it has > exported [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 37564
Cc: Eli Zaretskii <eliz@HIDDEN>, 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Matthew Leach <matthew@HIDDEN> writes:

>> I simply tried "env | fgrep LINES" and I do see the variable, although
>> it wasn't there before I launched Emacs.
>
> I would expect the variable to be there when inside Emacs as it has
> exported it.  You should find that it won't exist if ran outside Emacs,
> for example in xterm.

I tried this in my bash here (under the "Terminal" program in Debian):

larsi@marnie:~/src/emacs/trunk$ set | grep LINES
LINES=24
larsi@marnie:~/src/emacs/trunk$ set | grep COLUMNS
COLUMNS=80

So they're in my env at least.

But I see I have this in my very ancient ~/.bashrc:

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 4 Oct 2019 18:48:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 04 14:48:50 2019
Received: from localhost ([127.0.0.1]:43470 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iGSdG-0007de-Ck
	for submit <at> debbugs.gnu.org; Fri, 04 Oct 2019 14:48:50 -0400
Received: from mx0.mattleach.net ([176.58.118.143]:55366)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <matthew@HIDDEN>) id 1iGSdE-0007dW-Sm
 for 37564 <at> debbugs.gnu.org; Fri, 04 Oct 2019 14:48:49 -0400
Received: by mx0.mattleach.net (Postfix, from userid 99)
 id 6CD0F61C21; Fri,  4 Oct 2019 19:48:48 +0100 (BST)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mx0.mattleach.net
X-Spam-Level: 
X-Spam-Status: No, score=-1.0 required=4.0 tests=ALL_TRUSTED
 autolearn=disabled version=3.4.2
Received: from hopton.mattleach.net (92.40.249.172.threembb.co.uk
 [92.40.249.172])
 by mx0.mattleach.net (Postfix) with ESMTPSA id AC41B61C21;
 Fri,  4 Oct 2019 19:48:45 +0100 (BST)
From: Matthew Leach <matthew@HIDDEN>
To: Glenn Morris <rgm@HIDDEN>
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
In-Reply-To: <9ipnjdemzv.fsf@HIDDEN> (Glenn Morris's message of
 "Thu, 03 Oct 2019 13:51:16 -0400")
References: <87y2y5lfnb.fsf@HIDDEN> <83eezxatsv.fsf@HIDDEN>
 <87tv8slb6w.fsf@HIDDEN> <83a7aka1q5.fsf@HIDDEN>
 <87sgocfh8c.fsf@HIDDEN> <83y2y48f8u.fsf@HIDDEN>
 <87o8z0few1.fsf@HIDDEN> <83sgob98zk.fsf@HIDDEN>
 <9ipnjdemzv.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
Date: Fri, 04 Oct 2019 19:48:49 +0100
Message-ID: <878sq0jqi6.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 37564
Cc: Eli Zaretskii <eliz@HIDDEN>, 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Glenn Morris <rgm@HIDDEN> writes:

> I think the point is that no terminal emulator / shell combination
> actually exports LINES and COLUMNS as environment variables, except for
> Emacs term.el. So no application can be relying on the LINES and COLUMNS
> environment variables (since there aren't any applications specifically
> for use inside Emacs's term). So term.el should stop setting them, since
> it actually causes problems.

Exactly that.  By exporting these variables it's causing more problems
than it solves.
-- 
Matt




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 4 Oct 2019 18:47:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 04 14:47:44 2019
Received: from localhost ([127.0.0.1]:43464 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iGScC-0007bd-0L
	for submit <at> debbugs.gnu.org; Fri, 04 Oct 2019 14:47:44 -0400
Received: from mx0.mattleach.net ([176.58.118.143]:55348)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <matthew@HIDDEN>) id 1iGSc9-0007bT-6r
 for 37564 <at> debbugs.gnu.org; Fri, 04 Oct 2019 14:47:41 -0400
Received: by mx0.mattleach.net (Postfix, from userid 99)
 id 8AC2161C5D; Fri,  4 Oct 2019 19:47:39 +0100 (BST)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mx0.mattleach.net
X-Spam-Level: 
X-Spam-Status: No, score=-1.0 required=4.0 tests=ALL_TRUSTED
 autolearn=disabled version=3.4.2
Received: from hopton.mattleach.net (92.40.249.172.threembb.co.uk
 [92.40.249.172])
 by mx0.mattleach.net (Postfix) with ESMTPSA id A7CC361C21;
 Fri,  4 Oct 2019 19:47:38 +0100 (BST)
From: Matthew Leach <matthew@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
In-Reply-To: <83sgob98zk.fsf@HIDDEN> (Eli Zaretskii's message of "Wed, 02 Oct
 2019 05:28:15 +0300")
References: <87y2y5lfnb.fsf@HIDDEN> <83eezxatsv.fsf@HIDDEN>
 <87tv8slb6w.fsf@HIDDEN> <83a7aka1q5.fsf@HIDDEN>
 <87sgocfh8c.fsf@HIDDEN> <83y2y48f8u.fsf@HIDDEN>
 <87o8z0few1.fsf@HIDDEN> <83sgob98zk.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
Date: Fri, 04 Oct 2019 19:47:41 +0100
Message-ID: <87d0fcjqk2.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 37564
Cc: 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Matthew Leach <matthew@HIDDEN>
>> Cc: 37564 <at> debbugs.gnu.org
>> Date: Tue, 01 Oct 2019 20:24:14 +0100
>> 
>> > I simply tried "env | fgrep LINES" and I do see the variable, although
>> > it wasn't there before I launched Emacs.
>> 
>> I would expect the variable to be there when inside Emacs as it has
>> exported it.  You should find that it won't exist if ran outside Emacs,
>> for example in xterm.
>
> Sorry, I'm confused.  Are we talking about running "M-x term" inside
> Emacs, or are we talking about something else?  The subject of the bug
> report says "term", so I assumed you mean term-mode.

Indeed, I'm talking about term-mode (M-x term). Sorry if I didn't make
that clear.

>> Ah, indeed if I try and resize and print the variable it has updated:
>> 
>> matthew@hopton ~ $ env | grep -i lines
>> LINES=30
>> matthew@hopton ~ $ env | grep -i lines
>> LINES=12
>> 
>> I think the issue is that the environment can't be while a process is
>> running; the environment variables are fixed when the program has
>> started. For a ncurses application this presents a problem as LINES and
>> COLUMNS can't be updated when the window size is changed and the program
>> handles a SIGWINCH. You can see that on the output above.
>
> While the process is running, Emacs sends ioctl commands to
> communicate the window size changes.

Sure but by exporting LINES and COLUMNS (something that other terminal
emulators don't do) programs aren't picking up changes in the window
size.

-- 
Matt




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 3 Oct 2019 17:51:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 03 13:51:27 2019
Received: from localhost ([127.0.0.1]:41098 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iG5GB-0004Td-2p
	for submit <at> debbugs.gnu.org; Thu, 03 Oct 2019 13:51:27 -0400
Received: from eggs.gnu.org ([209.51.188.92]:56749)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rgm@HIDDEN>) id 1iG5G9-0004TQ-1O
 for 37564 <at> debbugs.gnu.org; Thu, 03 Oct 2019 13:51:25 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:49564)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <rgm@HIDDEN>)
 id 1iG5G3-0006yc-GD; Thu, 03 Oct 2019 13:51:19 -0400
Received: from rgm by fencepost.gnu.org with local (Exim 4.82)
 (envelope-from <rgm@HIDDEN>)
 id 1iG5G1-0006jC-0o; Thu, 03 Oct 2019 13:51:17 -0400
From: Glenn Morris <rgm@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
References: <87y2y5lfnb.fsf@HIDDEN> <83eezxatsv.fsf@HIDDEN>
 <87tv8slb6w.fsf@HIDDEN> <83a7aka1q5.fsf@HIDDEN>
 <87sgocfh8c.fsf@HIDDEN> <83y2y48f8u.fsf@HIDDEN>
 <87o8z0few1.fsf@HIDDEN> <83sgob98zk.fsf@HIDDEN>
X-Spook: Interstate 2600 dedicated denial of service Closure Foot
X-Ran: L2}yP(H|HJwj^)]I-X%OGt]r`Es`8o8ZzVMmhm#My<i3r^sjuZjDHD`)H47e8ySkjxjL'J
X-Hue: magenta
X-Debbugs-No-Ack: yes
X-Attribution: GM
Date: Thu, 03 Oct 2019 13:51:16 -0400
In-Reply-To: <83sgob98zk.fsf@HIDDEN> (Eli Zaretskii's message of "Wed, 02 Oct
 2019 05:28:15 +0300")
Message-ID: <9ipnjdemzv.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: 37564
Cc: Matthew Leach <matthew@HIDDEN>, 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)


I think the point is that no terminal emulator / shell combination
actually exports LINES and COLUMNS as environment variables, except for
Emacs term.el. So no application can be relying on the LINES and COLUMNS
environment variables (since there aren't any applications specifically
for use inside Emacs's term). So term.el should stop setting them, since
it actually causes problems.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 2 Oct 2019 02:28:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 01 22:28:38 2019
Received: from localhost ([127.0.0.1]:35266 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iFUNa-0006M8-BQ
	for submit <at> debbugs.gnu.org; Tue, 01 Oct 2019 22:28:38 -0400
Received: from eggs.gnu.org ([209.51.188.92]:32851)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1iFUNX-0006Lu-Jq
 for 37564 <at> debbugs.gnu.org; Tue, 01 Oct 2019 22:28:37 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:46504)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1iFUNQ-0001qi-U4; Tue, 01 Oct 2019 22:28:30 -0400
Received: from [176.228.60.248] (port=3350 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1iFUNO-0000i0-HI; Tue, 01 Oct 2019 22:28:28 -0400
Date: Wed, 02 Oct 2019 05:28:15 +0300
Message-Id: <83sgob98zk.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Matthew Leach <matthew@HIDDEN>
In-reply-to: <87o8z0few1.fsf@HIDDEN> (message from Matthew Leach on
 Tue, 01 Oct 2019 20:24:14 +0100)
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
References: <87y2y5lfnb.fsf@HIDDEN> <83eezxatsv.fsf@HIDDEN>
 <87tv8slb6w.fsf@HIDDEN> <83a7aka1q5.fsf@HIDDEN>
 <87sgocfh8c.fsf@HIDDEN> <83y2y48f8u.fsf@HIDDEN>
 <87o8z0few1.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 37564
Cc: 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Matthew Leach <matthew@HIDDEN>
> Cc: 37564 <at> debbugs.gnu.org
> Date: Tue, 01 Oct 2019 20:24:14 +0100
> 
> > I simply tried "env | fgrep LINES" and I do see the variable, although
> > it wasn't there before I launched Emacs.
> 
> I would expect the variable to be there when inside Emacs as it has
> exported it.  You should find that it won't exist if ran outside Emacs,
> for example in xterm.

Sorry, I'm confused.  Are we talking about running "M-x term" inside
Emacs, or are we talking about something else?  The subject of the bug
report says "term", so I assumed you mean term-mode.

> Ah, indeed if I try and resize and print the variable it has updated:
> 
> matthew@hopton ~ $ env | grep -i lines
> LINES=30
> matthew@hopton ~ $ env | grep -i lines
> LINES=12
> 
> I think the issue is that the environment can't be while a process is
> running; the environment variables are fixed when the program has
> started. For a ncurses application this presents a problem as LINES and
> COLUMNS can't be updated when the window size is changed and the program
> handles a SIGWINCH. You can see that on the output above.

While the process is running, Emacs sends ioctl commands to
communicate the window size changes.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 1 Oct 2019 19:24:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 01 15:24:16 2019
Received: from localhost ([127.0.0.1]:34816 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iFNku-0005lP-Gr
	for submit <at> debbugs.gnu.org; Tue, 01 Oct 2019 15:24:16 -0400
Received: from mx0.mattleach.net ([176.58.118.143]:53080)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <matthew@HIDDEN>) id 1iFNkr-0005lD-KF
 for 37564 <at> debbugs.gnu.org; Tue, 01 Oct 2019 15:24:15 -0400
Received: by mx0.mattleach.net (Postfix, from userid 99)
 id 91D9961C91; Tue,  1 Oct 2019 20:24:12 +0100 (BST)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mx0.mattleach.net
X-Spam-Level: 
X-Spam-Status: No, score=-1.0 required=4.0 tests=ALL_TRUSTED,URIBL_BLOCKED
 autolearn=disabled version=3.4.2
Received: from hopton.mattleach.net (92.40.249.172.threembb.co.uk
 [92.40.249.172])
 by mx0.mattleach.net (Postfix) with ESMTPSA id A292461C21;
 Tue,  1 Oct 2019 20:24:11 +0100 (BST)
From: Matthew Leach <matthew@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
In-Reply-To: <83y2y48f8u.fsf@HIDDEN> (Eli Zaretskii's message of "Tue, 01 Oct
 2019 21:58:25 +0300")
References: <87y2y5lfnb.fsf@HIDDEN> <83eezxatsv.fsf@HIDDEN>
 <87tv8slb6w.fsf@HIDDEN> <83a7aka1q5.fsf@HIDDEN>
 <87sgocfh8c.fsf@HIDDEN> <83y2y48f8u.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
Date: Tue, 01 Oct 2019 20:24:14 +0100
Message-ID: <87o8z0few1.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 37564
Cc: 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Matthew Leach <matthew@HIDDEN>
>> Cc: 37564 <at> debbugs.gnu.org
>> Date: Tue, 01 Oct 2019 19:33:39 +0100
>> 
>> >> I'm curious as to which programs you are referring? AFAIK, if a program
>> >> tries to read the LINES and COLUMNS environment variables, using
>> >> `getenv()', they don't exist.
>> >
>> > What makes you say that? 
>> 
>> If I run the C program in my previous post in an xterm and resize I get:
>> 
>> getenv: (null) (null)
>> ioctl:  24 80
>> getenv: (null) (null)
>> ioctl:  42 169
>> 
>> You can see that doing getenv() on LINES and COLUMNS returns a null
>> pointer.  I've tested this same behaviour on gnome-terminal and numerous
>> other terminal emulators.
>
> I simply tried "env | fgrep LINES" and I do see the variable, although
> it wasn't there before I launched Emacs.

I would expect the variable to be there when inside Emacs as it has
exported it.  You should find that it won't exist if ran outside Emacs,
for example in xterm.

> 'env' is just another program accessing the environment, right? I have
> no idea why your test program doesn't see that, but then I'm far from
> being an expert on these issues.

Indeed, it does see the variables if I run inside Emacs.  If I run it
outside then they are not there, on my machine anyway.

>> > Emacs exports these variables into the environment that is passed to
>> > child subprocesses, so those subprocesses will definitely see them
>> > using getenv.
>> 
>> I'm no expert on how these things work but it doesn't appear to be the
>> way that it's done, on my machine anyway.  Perhaps there are programs
>> that uses these variables on MacOS or Windows?
>
> I tried the above on a Trisquel GNU/Windows machine, FWIW.

I'm running on Arch GNU/Linux this end.

>> I'm testing this on the latest Emacs Git version. I can see that
>> window-adjust-process-window-size-function is used in term.el however,
>> this doesn't appear to update the environment variables exported to the
>> terminal process.
>
> AFAIR, it's supposed to send the corresponding ioctl command, in
> addition to setting LINES and COLUMNS.
>
>> If I run the same program with term on Emacs git and
>> resize I get:
>> 
>> getenv: 31 80
>> ioctl:  30 89
>> getenv: 31 80
>> ioctl:  30 90
>> getenv: 31 80
>> ioctl:  30 91
>> getenv: 31 80
>> ioctl:  31 92
>> getenv: 31 80
>> ioctl:  31 93
>> getenv: 31 80
>> ioctl:  31 94
>> ...
>> 
>> Notice that the values returned by getenv don't change.
>
> Again, the "env | fgrep LINES" method does show the change when I
> resize the window on the machine I tried this, so I'm unsure why you
> don't see it.

Ah, indeed if I try and resize and print the variable it has updated:

matthew@hopton ~ $ env | grep -i lines
LINES=30
matthew@hopton ~ $ env | grep -i lines
LINES=12

I think the issue is that the environment can't be while a process is
running; the environment variables are fixed when the program has
started. For a ncurses application this presents a problem as LINES and
COLUMNS can't be updated when the window size is changed and the program
handles a SIGWINCH. You can see that on the output above.

>> Given that this functionality is broken, I'm suggesting that we don't
>> export the variables.
>
> I don't agree that it's broken; it isn't for me.  I think someone who
> understands more than I do about this stuff should chime in and
> explain why we see such different results.

I think the above explains what's going on. Perhaps that's why terminal
emulators don't export LINES and COLUMNS to programs so an ioctl() is used
instead?
-- 
Matt




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 1 Oct 2019 19:15:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 01 15:15:13 2019
Received: from localhost ([127.0.0.1]:34792 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iFNc9-0003en-DE
	for submit <at> debbugs.gnu.org; Tue, 01 Oct 2019 15:15:13 -0400
Received: from eggs.gnu.org ([209.51.188.92]:37562)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1iFNc7-0003Xe-RP
 for 37564 <at> debbugs.gnu.org; Tue, 01 Oct 2019 15:15:12 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:39307)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1iFNc2-0003B8-F8; Tue, 01 Oct 2019 15:15:06 -0400
Received: from [176.228.60.248] (port=4843 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1iFNbz-00041e-6i; Tue, 01 Oct 2019 15:15:05 -0400
Date: Tue, 01 Oct 2019 22:14:38 +0300
Message-Id: <83tv8s8eht.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: matthew@HIDDEN
In-reply-to: <83y2y48f8u.fsf@HIDDEN> (message from Eli Zaretskii on Tue, 01
 Oct 2019 21:58:25 +0300)
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
References: <87y2y5lfnb.fsf@HIDDEN> <83eezxatsv.fsf@HIDDEN>
 <87tv8slb6w.fsf@HIDDEN> <83a7aka1q5.fsf@HIDDEN>
 <87sgocfh8c.fsf@HIDDEN> <83y2y48f8u.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 37564
Cc: 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Tue, 01 Oct 2019 21:58:25 +0300
> From: Eli Zaretskii <eliz@HIDDEN>
> Cc: 37564 <at> debbugs.gnu.org
> 
> I tried the above on a Trisquel GNU/Windows machine, FWIW.

I meant GNU/Linux, of course.  Sorry...




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 1 Oct 2019 18:58:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 01 14:58:57 2019
Received: from localhost ([127.0.0.1]:34769 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iFNMO-00030s-La
	for submit <at> debbugs.gnu.org; Tue, 01 Oct 2019 14:58:56 -0400
Received: from eggs.gnu.org ([209.51.188.92]:35301)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1iFNML-00030c-Ni
 for 37564 <at> debbugs.gnu.org; Tue, 01 Oct 2019 14:58:55 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:38984)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1iFNMG-0005Tk-9H; Tue, 01 Oct 2019 14:58:48 -0400
Received: from [176.228.60.248] (port=3833 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1iFNMD-0004ng-0M; Tue, 01 Oct 2019 14:58:47 -0400
Date: Tue, 01 Oct 2019 21:58:25 +0300
Message-Id: <83y2y48f8u.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Matthew Leach <matthew@HIDDEN>
In-reply-to: <87sgocfh8c.fsf@HIDDEN> (message from Matthew Leach on
 Tue, 01 Oct 2019 19:33:39 +0100)
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
References: <87y2y5lfnb.fsf@HIDDEN> <83eezxatsv.fsf@HIDDEN>
 <87tv8slb6w.fsf@HIDDEN> <83a7aka1q5.fsf@HIDDEN>
 <87sgocfh8c.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 37564
Cc: 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Matthew Leach <matthew@HIDDEN>
> Cc: 37564 <at> debbugs.gnu.org
> Date: Tue, 01 Oct 2019 19:33:39 +0100
> 
> >> I'm curious as to which programs you are referring? AFAIK, if a program
> >> tries to read the LINES and COLUMNS environment variables, using
> >> `getenv()', they don't exist.
> >
> > What makes you say that? 
> 
> If I run the C program in my previous post in an xterm and resize I get:
> 
> getenv: (null) (null)
> ioctl:  24 80
> getenv: (null) (null)
> ioctl:  42 169
> 
> You can see that doing getenv() on LINES and COLUMNS returns a null
> pointer.  I've tested this same behaviour on gnome-terminal and numerous
> other terminal emulators.

I simply tried "env | fgrep LINES" and I do see the variable, although
it wasn't there before I launched Emacs.  'env' is just another
program accessing the environment, right?  I have no idea why your
test program doesn't see that, but then I'm far from being an expert
on these issues.

> > Emacs exports these variables into the environment that is passed to
> > child subprocesses, so those subprocesses will definitely see them
> > using getenv.
> 
> I'm no expert on how these things work but it doesn't appear to be the
> way that it's done, on my machine anyway.  Perhaps there are programs
> that uses these variables on MacOS or Windows?

I tried the above on a Trisquel GNU/Windows machine, FWIW.

> I'm testing this on the latest Emacs Git version. I can see that
> window-adjust-process-window-size-function is used in term.el however,
> this doesn't appear to update the environment variables exported to the
> terminal process.

AFAIR, it's supposed to send the corresponding ioctl command, in
addition to setting LINES and COLUMNS.

> If I run the same program with term on Emacs git and
> resize I get:
> 
> getenv: 31 80
> ioctl:  30 89
> getenv: 31 80
> ioctl:  30 90
> getenv: 31 80
> ioctl:  30 91
> getenv: 31 80
> ioctl:  31 92
> getenv: 31 80
> ioctl:  31 93
> getenv: 31 80
> ioctl:  31 94
> ...
> 
> Notice that the values returned by getenv don't change.

Again, the "env | fgrep LINES" method does show the change when I
resize the window on the machine I tried this, so I'm unsure why you
don't see it.

> Given that this functionality is broken, I'm suggesting that we don't
> export the variables.

I don't agree that it's broken; it isn't for me.  I think someone who
understands more than I do about this stuff should chime in and
explain why we see such different results.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 1 Oct 2019 18:33:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 01 14:33:41 2019
Received: from localhost ([127.0.0.1]:34749 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iFMxx-0002MS-0n
	for submit <at> debbugs.gnu.org; Tue, 01 Oct 2019 14:33:41 -0400
Received: from mx0.mattleach.net ([176.58.118.143]:52748)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <matthew@HIDDEN>) id 1iFMxu-0002MJ-Bw
 for 37564 <at> debbugs.gnu.org; Tue, 01 Oct 2019 14:33:39 -0400
Received: by mx0.mattleach.net (Postfix, from userid 99)
 id 6C2C161C5D; Tue,  1 Oct 2019 19:33:37 +0100 (BST)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mx0.mattleach.net
X-Spam-Level: 
X-Spam-Status: No, score=-1.0 required=4.0 tests=ALL_TRUSTED,URIBL_BLOCKED
 autolearn=disabled version=3.4.2
Received: from hopton.mattleach.net (92.40.249.172.threembb.co.uk
 [92.40.249.172])
 by mx0.mattleach.net (Postfix) with ESMTPSA id 8F4CD61C21;
 Tue,  1 Oct 2019 19:33:36 +0100 (BST)
From: Matthew Leach <matthew@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
In-Reply-To: <83a7aka1q5.fsf@HIDDEN> (Eli Zaretskii's message of "Tue, 01 Oct
 2019 19:07:30 +0300")
References: <87y2y5lfnb.fsf@HIDDEN> <83eezxatsv.fsf@HIDDEN>
 <87tv8slb6w.fsf@HIDDEN> <83a7aka1q5.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
Date: Tue, 01 Oct 2019 19:33:39 +0100
Message-ID: <87sgocfh8c.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 37564
Cc: 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Matthew Leach <matthew@HIDDEN>
>> Cc: 37564 <at> debbugs.gnu.org
>> Date: Tue, 01 Oct 2019 16:47:35 +0100
>> 
>> > Thanks, but I don't think we can make this change unconditionally,
>> > because not all applications that heed LINES and COLUMNS use ncurses.
>> 
>> I'm curious as to which programs you are referring? AFAIK, if a program
>> tries to read the LINES and COLUMNS environment variables, using
>> `getenv()', they don't exist.
>
> What makes you say that? 

If I run the C program in my previous post in an xterm and resize I get:

getenv: (null) (null)
ioctl:  24 80
getenv: (null) (null)
ioctl:  42 169

You can see that doing getenv() on LINES and COLUMNS returns a null
pointer.  I've tested this same behaviour on gnome-terminal and numerous
other terminal emulators.

> Emacs exports these variables into the environment that is passed to
> child subprocesses, so those subprocesses will definitely see them
> using getenv.

I'm no expert on how these things work but it doesn't appear to be the
way that it's done, on my machine anyway.  Perhaps there are programs
that uses these variables on MacOS or Windows?

>> Nevertheless, if a program does read the LINES and COLUMNS variables,
>> these values will be wrong if the window has been resized (try and
>> compile the attached C snippet and run in term mode while resizing the
>> window). Should that be considered as a separate bug?
>
> We nowadays have window-adjust-process-window-size-function to support
> that, and term.el is using that.  So why isn't it working for you?
> Maybe you are running a version of Emacs that's too old (AFAICT, you
> didn't say which one)?

I'm testing this on the latest Emacs Git version. I can see that
window-adjust-process-window-size-function is used in term.el however,
this doesn't appear to update the environment variables exported to the
terminal process. If I run the same program with term on Emacs git and
resize I get:

getenv: 31 80
ioctl:  30 89
getenv: 31 80
ioctl:  30 90
getenv: 31 80
ioctl:  30 91
getenv: 31 80
ioctl:  31 92
getenv: 31 80
ioctl:  31 93
getenv: 31 80
ioctl:  31 94
...

Notice that the values returned by getenv don't change.

Given that this functionality is broken, I'm suggesting that we don't
export the variables. This will make ncurses fall back to using ioctls
for window size inspection. Another way to fix this would be to somehow
update the environment variables that are exported to the process. What
are your thoughts?

Thanks,
-- 
Matt




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 1 Oct 2019 16:07:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 01 12:07:39 2019
Received: from localhost ([127.0.0.1]:34555 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iFKgd-00057p-6O
	for submit <at> debbugs.gnu.org; Tue, 01 Oct 2019 12:07:39 -0400
Received: from eggs.gnu.org ([209.51.188.92]:43416)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1iFKgb-00057c-0m
 for 37564 <at> debbugs.gnu.org; Tue, 01 Oct 2019 12:07:37 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:35729)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1iFKgV-0006ft-5s; Tue, 01 Oct 2019 12:07:31 -0400
Received: from [176.228.60.248] (port=1401 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1iFKgU-0006f1-H5; Tue, 01 Oct 2019 12:07:31 -0400
Date: Tue, 01 Oct 2019 19:07:30 +0300
Message-Id: <83a7aka1q5.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Matthew Leach <matthew@HIDDEN>
In-reply-to: <87tv8slb6w.fsf@HIDDEN> (message from Matthew Leach on
 Tue, 01 Oct 2019 16:47:35 +0100)
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
References: <87y2y5lfnb.fsf@HIDDEN> <83eezxatsv.fsf@HIDDEN>
 <87tv8slb6w.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 37564
Cc: 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Matthew Leach <matthew@HIDDEN>
> Cc: 37564 <at> debbugs.gnu.org
> Date: Tue, 01 Oct 2019 16:47:35 +0100
> 
> > Thanks, but I don't think we can make this change unconditionally,
> > because not all applications that heed LINES and COLUMNS use ncurses.
> 
> I'm curious as to which programs you are referring? AFAIK, if a program
> tries to read the LINES and COLUMNS environment variables, using
> `getenv()', they don't exist.

What makes you say that?  Emacs exports these variables into the
environment that is passed to child subprocesses, so those
subprocesses will definitely see them using getenv.

> Nevertheless, if a program does read the LINES and COLUMNS variables,
> these values will be wrong if the window has been resized (try and
> compile the attached C snippet and run in term mode while resizing the
> window). Should that be considered as a separate bug?

We nowadays have window-adjust-process-window-size-function to support
that, and term.el is using that.  So why isn't it working for you?
Maybe you are running a version of Emacs that's too old (AFAICT, you
didn't say which one)?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 1 Oct 2019 15:47:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 01 11:47:42 2019
Received: from localhost ([127.0.0.1]:34461 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iFKNK-0002Qs-3G
	for submit <at> debbugs.gnu.org; Tue, 01 Oct 2019 11:47:42 -0400
Received: from mx0.mattleach.net ([176.58.118.143]:51342)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <matthew@HIDDEN>) id 1iFKNH-0002Qj-Gw
 for 37564 <at> debbugs.gnu.org; Tue, 01 Oct 2019 11:47:41 -0400
Received: by mx0.mattleach.net (Postfix, from userid 99)
 id 66D8661C5D; Tue,  1 Oct 2019 16:47:38 +0100 (BST)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mx0.mattleach.net
X-Spam-Level: 
X-Spam-Status: No, score=-1.0 required=4.0 tests=ALL_TRUSTED,URIBL_BLOCKED
 autolearn=disabled version=3.4.2
Received: from hopton.mattleach.net (92.40.249.172.threembb.co.uk
 [92.40.249.172])
 by mx0.mattleach.net (Postfix) with ESMTPSA id 98DAB61C21;
 Tue,  1 Oct 2019 16:47:37 +0100 (BST)
From: Matthew Leach <matthew@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
In-Reply-To: <83eezxatsv.fsf@HIDDEN> (Eli Zaretskii's message of "Tue, 01 Oct
 2019 09:01:04 +0300")
References: <87y2y5lfnb.fsf@HIDDEN> <83eezxatsv.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
Date: Tue, 01 Oct 2019 16:47:35 +0100
Message-ID: <87tv8slb6w.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 37564
Cc: 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Matthew Leach <matthew@HIDDEN>
>> Date: Mon, 30 Sep 2019 20:59:04 +0100
>> 
>> 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.
>
> Thanks, but I don't think we can make this change unconditionally,
> because not all applications that heed LINES and COLUMNS use ncurses.

I'm curious as to which programs you are referring? AFAIK, if a program
tries to read the LINES and COLUMNS environment variables, using
`getenv()', they don't exist. Running 'echo $LINES' on a bash terminal
seems to actually do an ioctl to obtain the value of LINES.

Nevertheless, if a program does read the LINES and COLUMNS variables,
these values will be wrong if the window has been resized (try and
compile the attached C snippet and run in term mode while resizing the
window). Should that be considered as a separate bug?

> I wonder if we can do better than just providing a defcustom.

I could make this a defcustom if that would get the patch in?

Thanks,
-- 
Matt

--=-=-=
Content-Type: text/plain
Content-Disposition: inline; filename=winch2.c

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/ioctl.h>

void handle_sig()
{
    struct winsize w;
    ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);

    printf("getenv: %s %s\n", getenv("LINES"), getenv("COLUMNS"));
    printf("ioctl:  %d %d\n", w.ws_row, w.ws_col);
}

int main()
{
    signal(SIGWINCH, handle_sig);
    fgetc(stdin);
    return 0;
}

--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at 37564 <at> debbugs.gnu.org:


Received: (at 37564) by debbugs.gnu.org; 1 Oct 2019 06:01:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 01 02:01:15 2019
Received: from localhost ([127.0.0.1]:60789 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iFBDm-000372-Mp
	for submit <at> debbugs.gnu.org; Tue, 01 Oct 2019 02:01:15 -0400
Received: from eggs.gnu.org ([209.51.188.92]:33224)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1iFBDk-00036q-U3
 for 37564 <at> debbugs.gnu.org; Tue, 01 Oct 2019 02:01:13 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:55042)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1iFBDf-0000RR-GQ; Tue, 01 Oct 2019 02:01:07 -0400
Received: from [176.228.60.248] (port=3778 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1iFBDe-0003BH-4a; Tue, 01 Oct 2019 02:01:07 -0400
Date: Tue, 01 Oct 2019 09:01:04 +0300
Message-Id: <83eezxatsv.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Matthew Leach <matthew@HIDDEN>
In-reply-to: <87y2y5lfnb.fsf@HIDDEN> (message from Matthew Leach on Mon, 30
 Sep 2019 20:59:04 +0100)
Subject: Re: bug#37564: [PATCH] don't export LINES and COLUMNS env vars in
 term to fix ncurses applications
References: <87y2y5lfnb.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 37564
Cc: 37564 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Matthew Leach <matthew@HIDDEN>
> Date: Mon, 30 Sep 2019 20:59:04 +0100
> 
> 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.

Thanks, but I don't think we can make this change unconditionally,
because not all applications that heed LINES and COLUMNS use ncurses.
I wonder if we can do better than just providing a defcustom.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 30 Sep 2019 19:59:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 30 15:59:18 2019
Received: from localhost ([127.0.0.1]:60535 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iF1pF-0004Y7-QE
	for submit <at> debbugs.gnu.org; Mon, 30 Sep 2019 15:59:18 -0400
Received: from lists.gnu.org ([209.51.188.17]:42093)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <matthew@HIDDEN>) id 1iF1pE-0004Xy-8Q
 for submit <at> debbugs.gnu.org; Mon, 30 Sep 2019 15:59:16 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:42086)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <matthew@HIDDEN>) id 1iF1pC-0004zR-R4
 for bug-gnu-emacs@HIDDEN; Mon, 30 Sep 2019 15:59:16 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <matthew@HIDDEN>) id 1iF1pA-0001ms-Df
 for bug-gnu-emacs@HIDDEN; Mon, 30 Sep 2019 15:59:13 -0400
Received: from mx0.mattleach.net ([176.58.118.143]:60130)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <matthew@HIDDEN>) id 1iF1pA-0001lL-5p
 for bug-gnu-emacs@HIDDEN; Mon, 30 Sep 2019 15:59:12 -0400
Received: by mx0.mattleach.net (Postfix, from userid 99)
 id 97FCE61C5D; Mon, 30 Sep 2019 20:59:07 +0100 (BST)
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 <bug-gnu-emacs@HIDDEN>; Mon, 30 Sep 2019 20:59:06 +0100 (BST)
From: Matthew Leach <matthew@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] don't export LINES and COLUMNS env vars in term to fix
 ncurses applications
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
Date: Mon, 30 Sep 2019 20:59:04 +0100
Message-ID: <87y2y5lfnb.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-Received-From: 176.58.118.143
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

--=-=-=
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
<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)


--=-=-=
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 <matthew@HIDDEN>
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

--=-=-=--




Acknowledgement sent to Matthew Leach <matthew@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#37564; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 8 Oct 2019 16:45:01 UTC

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