aboutsummaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
Diffstat (limited to 'win32')
-rw-r--r--win32/winansi.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/win32/winansi.c b/win32/winansi.c
index dcfdd7e1f..c4c7ee87c 100644
--- a/win32/winansi.c
+++ b/win32/winansi.c
@@ -53,17 +53,14 @@ static int is_console_in(int fd)
53 return isatty(fd) && GetStdHandle(STD_INPUT_HANDLE) != INVALID_HANDLE_VALUE; 53 return isatty(fd) && GetStdHandle(STD_INPUT_HANDLE) != INVALID_HANDLE_VALUE;
54} 54}
55 55
56static int skip_ansi_emulation(void) 56int skip_ansi_emulation(int reset)
57{ 57{
58 static char *var = NULL; 58 static int skip = -1;
59 static int got_var = FALSE;
60 59
61 if (!got_var) { 60 if (skip < 0 || reset)
62 var = getenv("BB_SKIP_ANSI_EMULATION"); 61 skip = getenv(bb_skip_ansi_emulation) != NULL;
63 got_var = TRUE;
64 }
65 62
66 return var != NULL; 63 return skip;
67} 64}
68 65
69void set_title(const char *str) 66void set_title(const char *str)
@@ -557,7 +554,7 @@ static int ansi_emulate(const char *s, FILE *stream)
557 554
558 while (*pos) { 555 while (*pos) {
559 pos = strchr(str, '\033'); 556 pos = strchr(str, '\033');
560 if (pos && !skip_ansi_emulation()) { 557 if (pos && !skip_ansi_emulation(FALSE)) {
561 size_t len = pos - str; 558 size_t len = pos - str;
562 559
563 if (len) { 560 if (len) {
@@ -811,7 +808,7 @@ static int ansi_emulate_write(int fd, const void *buf, size_t count)
811 /* we've checked the data doesn't contain any NULs */ 808 /* we've checked the data doesn't contain any NULs */
812 while (*pos) { 809 while (*pos) {
813 pos = strchr(str, '\033'); 810 pos = strchr(str, '\033');
814 if (pos && !skip_ansi_emulation()) { 811 if (pos && !skip_ansi_emulation(FALSE)) {
815 len = pos - str; 812 len = pos - str;
816 813
817 if (len) { 814 if (len) {