From 8c3c113f03d539cf15dd855273ec12f98091feff Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Wed, 14 Apr 2010 00:47:18 +0200 Subject: win32: ash: work around case-insensitive env vars --- shell/ash.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index ed892db98..64e64d95e 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -13216,6 +13216,33 @@ init(void) struct stat st1, st2; initvar(); + +#if ENABLE_PLATFORM_MINGW32 + /* + * case insensitive env names from Windows world + * + * Some standard env names such as PATH is named Path and so on + * ash itself is case sensitive, so "Path" will confuse it, as + * MSVC getenv() is case insensitive. + * + * We may end up having both Path and PATH. Then Path will be chosen + * because it appears first. + */ + for (envp = environ; envp && *envp; envp++) + if (!strncasecmp(*envp, "PATH=", 5) && + strncmp(*envp, "PATH=", 5)) + break; + if (envp && *envp) { + char *start, *end; + for (envp = environ; envp && *envp; envp++) { + end = strchr(*envp, '='); + if (!end) + continue; + for (start = *envp;start < end;start++) + *start = toupper(*start); + } + } +#endif for (envp = environ; envp && *envp; envp++) { if (strchr(*envp, '=')) { setvareq(*envp, VEXPORT|VTEXTFIXED); -- cgit v1.2.3-55-g6feb