diff options
author | Ron Yorston <rmy@pobox.com> | 2016-11-10 15:31:27 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2016-11-10 15:38:34 +0000 |
commit | 9fa1e4990e655a85025c9d270a1606983e375e47 (patch) | |
tree | cb540358a001eb2a4bdebc4de73a22a1daec7928 | |
parent | 550b6b0421d3f74c2c6ff3f8d9dfbc9e7ac22c3a (diff) | |
download | busybox-w32-9fa1e4990e655a85025c9d270a1606983e375e47.tar.gz busybox-w32-9fa1e4990e655a85025c9d270a1606983e375e47.tar.bz2 busybox-w32-9fa1e4990e655a85025c9d270a1606983e375e47.zip |
win32: allow ANSI emulation to be disabled
If the environment variable BB_SKIP_ANSI_EMULATION is set (the value
doesn't matter) escape sequences are passed through to the terminal.
-rw-r--r-- | win32/winansi.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/win32/winansi.c b/win32/winansi.c index 7069b8d80..e95b9c846 100644 --- a/win32/winansi.c +++ b/win32/winansi.c | |||
@@ -59,6 +59,19 @@ static void init(void) | |||
59 | initialized = 1; | 59 | initialized = 1; |
60 | } | 60 | } |
61 | 61 | ||
62 | static int skip_ansi_emulation(void) | ||
63 | { | ||
64 | static char *var = NULL; | ||
65 | static int got_var = FALSE; | ||
66 | |||
67 | if (!got_var) { | ||
68 | var = getenv("BB_SKIP_ANSI_EMULATION"); | ||
69 | got_var = TRUE; | ||
70 | } | ||
71 | |||
72 | return var != NULL; | ||
73 | } | ||
74 | |||
62 | 75 | ||
63 | #define FOREGROUND_ALL (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE) | 76 | #define FOREGROUND_ALL (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE) |
64 | #define BACKGROUND_ALL (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE) | 77 | #define BACKGROUND_ALL (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE) |
@@ -399,7 +412,7 @@ static int ansi_emulate(const char *s, FILE *stream) | |||
399 | 412 | ||
400 | while (*pos) { | 413 | while (*pos) { |
401 | pos = strstr(str, "\033["); | 414 | pos = strstr(str, "\033["); |
402 | if (pos) { | 415 | if (pos && !skip_ansi_emulation()) { |
403 | size_t len = pos - str; | 416 | size_t len = pos - str; |
404 | 417 | ||
405 | if (len) { | 418 | if (len) { |
@@ -636,7 +649,7 @@ static int ansi_emulate_write(int fd, const void *buf, size_t count) | |||
636 | /* we've checked the data doesn't contain any NULs */ | 649 | /* we've checked the data doesn't contain any NULs */ |
637 | while (*pos) { | 650 | while (*pos) { |
638 | pos = strstr(str, "\033["); | 651 | pos = strstr(str, "\033["); |
639 | if (pos) { | 652 | if (pos && !skip_ansi_emulation()) { |
640 | len = pos - str; | 653 | len = pos - str; |
641 | 654 | ||
642 | if (len) { | 655 | if (len) { |