From eefae06bd0dc1e10c166155afab4b115439bc802 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 19 Feb 2023 10:05:18 +0000 Subject: win32: work around problem with ConEmu When running the busybox-w32 shell in ConEmu, if: - ANSI emulation is disabled (which it will be, by default) - a non-builtin command is run there is a window of a few seconds after the command completes during which ConEmu is in XTerm mode. During this time any attempt to use the arrows keys will result in [A[B[C[D appearing. This appears to be a common problem: https://github.com/Maximus5/ConEmu/issues/2316 Try to detect if we're running under ConEmu and alter the default behaviour to prefer ANSI emulation. The user can override this preference by setting BB_SKIP_ANSI_EMULATION if desired. By a quirk of fate, old MSYS2 programs (from 2021) which required a workaround in busybox-w32 (commit 54d2ea4b4) are immune to the problem with ConEmu. (GitHib issue #287) --- win32/winansi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/win32/winansi.c b/win32/winansi.c index 27559e3f5..1400ea3bb 100644 --- a/win32/winansi.c +++ b/win32/winansi.c @@ -77,7 +77,9 @@ int skip_ansi_emulation(int reset) if (skip < 0 || reset) { const char *var = getenv(BB_SKIP_ANSI_EMULATION); - int dflt = is_wine() ? 0 : CONFIG_SKIP_ANSI_EMULATION_DEFAULT; + int dflt = CONFIG_SKIP_ANSI_EMULATION_DEFAULT; + if (is_wine() || getenv("CONEMUPID") != NULL) + dflt = 0; skip = var == NULL ? dflt : atoi(var); if (skip < 0 || skip > 2) skip = 0; -- cgit v1.2.3-55-g6feb