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 | |
| 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.
| -rw-r--r-- | include/libbb.h | 1 | ||||
| -rw-r--r-- | include/mingw.h | 1 | ||||
| -rw-r--r-- | libbb/messages.c | 2 | ||||
| -rw-r--r-- | shell/ash.c | 11 | ||||
| -rw-r--r-- | win32/winansi.c | 17 |
5 files changed, 22 insertions, 10 deletions
diff --git a/include/libbb.h b/include/libbb.h index 8979665b2..7077f0e0d 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
| @@ -2215,6 +2215,7 @@ extern const char bb_busybox_exec_path[] ALIGN1; | |||
| 2215 | #define BB_PATH_ROOT_PATH "PATH=/sbin;/usr/sbin;/bin;/usr/bin" BB_ADDITIONAL_PATH | 2215 | #define BB_PATH_ROOT_PATH "PATH=/sbin;/usr/sbin;/bin;/usr/bin" BB_ADDITIONAL_PATH |
| 2216 | #define PATH_SEP ';' | 2216 | #define PATH_SEP ';' |
| 2217 | #define PATH_SEP_STR ";" | 2217 | #define PATH_SEP_STR ";" |
| 2218 | extern const char bb_skip_ansi_emulation[] ALIGN1; | ||
| 2218 | #endif | 2219 | #endif |
| 2219 | extern const char bb_PATH_root_path[] ALIGN1; /* BB_PATH_ROOT_PATH */ | 2220 | extern const char bb_PATH_root_path[] ALIGN1; /* BB_PATH_ROOT_PATH */ |
| 2220 | #define bb_default_root_path (bb_PATH_root_path + sizeof("PATH")) | 2221 | #define bb_default_root_path (bb_PATH_root_path + sizeof("PATH")) |
diff --git a/include/mingw.h b/include/mingw.h index 3516cd31c..0fead43c9 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
| @@ -538,3 +538,4 @@ char *xabsolute_path(char *path); | |||
| 538 | char *get_drive_cwd(const char *path, char *buffer, int size); | 538 | char *get_drive_cwd(const char *path, char *buffer, int size); |
| 539 | void fix_path_case(char *path); | 539 | void fix_path_case(char *path); |
| 540 | void seek_sparse(int fd, size_t size); | 540 | void seek_sparse(int fd, size_t size); |
| 541 | int skip_ansi_emulation(int reset); | ||
diff --git a/libbb/messages.c b/libbb/messages.c index f5bbd3e32..04863855a 100644 --- a/libbb/messages.c +++ b/libbb/messages.c | |||
| @@ -29,6 +29,8 @@ const char bb_hexdigits_upcase[] ALIGN1 = "0123456789ABCDEF"; | |||
| 29 | 29 | ||
| 30 | #if !ENABLE_PLATFORM_MINGW32 | 30 | #if !ENABLE_PLATFORM_MINGW32 |
| 31 | const char bb_busybox_exec_path[] ALIGN1 = CONFIG_BUSYBOX_EXEC_PATH; | 31 | const char bb_busybox_exec_path[] ALIGN1 = CONFIG_BUSYBOX_EXEC_PATH; |
| 32 | #else | ||
| 33 | const char bb_skip_ansi_emulation[] ALIGN1 = "BB_SKIP_ANSI_EMULATION"; | ||
| 32 | #endif | 34 | #endif |
| 33 | const char bb_default_login_shell[] ALIGN1 = LIBBB_DEFAULT_LOGIN_SHELL; | 35 | const char bb_default_login_shell[] ALIGN1 = LIBBB_DEFAULT_LOGIN_SHELL; |
| 34 | /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, | 36 | /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, |
diff --git a/shell/ash.c b/shell/ash.c index ca8acd705..4f1fe005b 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
| @@ -2248,6 +2248,14 @@ static void change_seconds(const char *) FAST_FUNC; | |||
| 2248 | static void change_realtime(const char *) FAST_FUNC; | 2248 | static void change_realtime(const char *) FAST_FUNC; |
| 2249 | #endif | 2249 | #endif |
| 2250 | 2250 | ||
| 2251 | #if ENABLE_PLATFORM_MINGW32 | ||
| 2252 | static void FAST_FUNC | ||
| 2253 | change_skip_ansi(const char *newval UNUSED_PARAM) | ||
| 2254 | { | ||
| 2255 | skip_ansi_emulation(TRUE); | ||
| 2256 | } | ||
| 2257 | #endif | ||
| 2258 | |||
| 2251 | static const struct { | 2259 | static const struct { |
| 2252 | int flags; | 2260 | int flags; |
| 2253 | const char *var_text; | 2261 | const char *var_text; |
| @@ -2284,6 +2292,9 @@ static const struct { | |||
| 2284 | #if ENABLE_FEATURE_EDITING_SAVEHISTORY | 2292 | #if ENABLE_FEATURE_EDITING_SAVEHISTORY |
| 2285 | { VSTRFIXED|VTEXTFIXED|VUNSET, "HISTFILE" , NULL }, | 2293 | { VSTRFIXED|VTEXTFIXED|VUNSET, "HISTFILE" , NULL }, |
| 2286 | #endif | 2294 | #endif |
| 2295 | #if ENABLE_PLATFORM_MINGW32 | ||
| 2296 | { VSTRFIXED|VTEXTFIXED|VUNSET, bb_skip_ansi_emulation, change_skip_ansi }, | ||
| 2297 | #endif | ||
| 2287 | }; | 2298 | }; |
| 2288 | 2299 | ||
| 2289 | struct redirtab; | 2300 | struct redirtab; |
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) { |
