diff options
author | Ron Yorston <rmy@pobox.com> | 2020-04-13 13:13:01 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-04-13 13:35:49 +0100 |
commit | 026bf90b29314486d64f93c0633dffda8ac58379 (patch) | |
tree | 3624c2be4bae9038eeaf49c5e80ceef5030d1390 /win32 | |
parent | 10e14d5ebdfdfe3acd1cd60692d9cffd07de04e2 (diff) | |
download | busybox-w32-026bf90b29314486d64f93c0633dffda8ac58379.tar.gz busybox-w32-026bf90b29314486d64f93c0633dffda8ac58379.tar.bz2 busybox-w32-026bf90b29314486d64f93c0633dffda8ac58379.zip |
ash: reset ANSI emulation when BB_SKIP_ANSI_EMULATION changes
Update the skip status on the first call to skip_ansi_emulation()
and whenever the BB_SKIP_ANSI_EMULATION variable changes.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/winansi.c | 17 |
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 | ||
56 | static int skip_ansi_emulation(void) | 56 | int 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 | ||
69 | void set_title(const char *str) | 66 | void 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) { |