From a236242374daf911a01e998fabb1cc1268b2be7b Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 14 Dec 2018 15:27:54 +0000 Subject: win32: special treatment for PATH The PATH shell variable is a special case. It can be exported to the environment where it might be interpreted by native applications which assume the separator is ';'. Hence: - require that the separator used in PATH is ';' - enforce this by intercepting calls to setvareq() that set PATH and adjusting its value if necessary. As a result of this the code to parse PATH can be simplified by replacing the hardcoded Unix ':' path separator by the platform- dependent macro PATH_SEP. The MANPATH variable is also required to use ';' as its separator but since it's less likely to be used this isn't enforced. --- libbb/executable.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'libbb/executable.c') diff --git a/libbb/executable.c b/libbb/executable.c index 835341ed9..87a40eeda 100644 --- a/libbb/executable.c +++ b/libbb/executable.c @@ -40,28 +40,21 @@ char* FAST_FUNC find_executable(const char *filename, char **PATHp) */ char *p, *n; #if ENABLE_PLATFORM_MINGW32 - char sep, *w; + char *w; #endif p = *PATHp; while (p) { int ex; -#if !ENABLE_PLATFORM_MINGW32 - n = strchr(p, ':'); + n = strchr(p, PATH_SEP); if (n) *n = '\0'; -#else - n = (char*)next_path_sep(p); - if (n) { sep = *n; *n = '\0'; } -#endif p = concat_path_file( p[0] ? p : ".", /* handle "::" case */ filename ); -#if !ENABLE_PLATFORM_MINGW32 - if (n) *n++ = ':'; -#else - if (n) *n++ = sep; + if (n) *n++ = PATH_SEP; +#if ENABLE_PLATFORM_MINGW32 if ((w=alloc_win32_extension(p))) { free(p); p = w; -- cgit v1.2.3-55-g6feb