This is the mail archive of the
mailing list for the Cygwin project.
Re: [PATCH] Cygwin: console, pty: Prevent error in legacy console mode.
On 2019-11-06 08:44, Takashi Yano wrote:
> On Wed, 6 Nov 2019 08:06:55 -0700
> Brian Inglis wrote:
>>> + if (con.is_legacy)
>>> + setenv ("TERM", "cygwin", 1);
>> handlers should not be changing user's env vars: that is the user's selection to
>> get their preferred operation in their apps.
>> If you need to set TERM, shouldn't you also set it appropriately for non-legacy
> The environment TERM is set to cygwin or xterm-256color in environ.cc
> based on wincap.has_con_24bit_colors().
> However, if legacy console mode is enabled, new terminal capability
> compatible with xterm is disabled. So TERM is override to cygwin by
> the code above.
> This is done only in the first initialization stage, so TERM value
> set by user in .login, .bashrc, .tcshrc and etc, ... will be kept.
> Only the case in which TERM is overrid is:
> 1) Enable console legacy mode.
> 2) Open command prompt.
> 3) set TERMq
> 4) start cygwin
> What situation do you assume this causes problem?
Is this not executed on every object creation and on every fork?
If that is not the case, then legacy_console/() should be a singleton
object/method, constructed when accessed, or in wincap, like
has_con_24bit_colors() - is_con_legacy().
When user explicitly sets TERM before starting Cygwin, or after forking, Cygwin
does not touch it, so you should not, and perhaps the legacy console check
should be added there:
The <envar>TERM</envar> environment variable specifies your terminal
type. It is automatically set to <literal>cygwin</literal> if you have
not set it to something else.
/* If console has 24 bit color capability, TERM=xterm-256color,
otherwise, TERM=cygwin */
- envp[i++] = strdup (wincap.has_con_24bit_colors () ? xterm : cygterm);
+ envp[i++] = strdup (wincap.has_con_24bit_colors () &&
!wincap.is_con_legacy() ? xterm : cygterm);
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.