git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] Windows: teach getenv to do a case-sensitive search

From
Karsten Blees <blees@dcon.de>
Date
Oct 5, 2011, 16:21 UTC
Message-ID
<loom.20111005T175934-633@post.gmane.org>
In-Reply-To
<4DEC7CDD.10403@viscovery.net>

Hmm...this looks like a pretty fragile solution to me. Wouldn't it be simpler and safer to just fix the conflicting variables, instead of inventing entirely new environment semantics for Windows?

I looked at the eval_gettext occurences, and only found '$path' in git-submodule.sh to obviously conflict with existing environment variables. So the straightforward solution IMO would be to fix the variable in that script.

Small solution (only affects gettext): in git-submodule.sh, replace all 'eval_gettext...$path' with 'modulepath=$path eval_gettext...$modulepath'

Big solution (enables git-submodule-foreach scripts on Windows, but is a breaking change for existing foreach scripts on Unix): in git-submodule.sh, t/t7407-submodule-foreach.sh, Documentation/git-submodule.txt, replace all '$path' with '$modulepath' (also a few 'path=...' and 'while read...path')

Just a few failure scenarios that come to mind with the current solution:
- Given environment variables "Path" and "path", the 'case-sensitive first'
approach works fine for 'getenv("path")', but 'getenv("PATH")' still has a 50%
chance of failure.
- The other environment functions have not been changed to reflect the
'case-sensitive first' logic: setenv("path"...) and setenv("PATH"...) both have
a chance of overwriting the wrong entry, same for putenv.
- Windows applications generally don't support case-sensitive environment
variables, e.g. all MSYS and Cygwin programs convert environment variable names
to upper case on startup, eliminating duplicates in the process. With git.exe
beeing the only case-sensitive tool, any change to git-sh-i18n.sh (e.g.
replacing git-envsubst with a real gettext-envsubst) is likely to break again.
- As you already mentioned, Windows doesn't support case-sensitive environment
variable names, MSDN is pretty clear on that. Expressly violating this
documentation may cease to work with any new Windows version or patch.

Cheers, Karsten

Previous: Johannes Sixt
Message 5 of 5 in “sh-i18n--envsubst; case-sensitive getenv on Windows”
  1. 0/3 sh-i18n--envsubst; case-sensitive getenv on WindowsJohannes Sixt, Jun 6, 2011
  2. 1/3 sh-i18n--envsubst: do not crash when no arguments are givenJohannes Sixt, Jun 6, 2011
  3. 2/3 mingw.c: move definition of mingw_getenv downJohannes Sixt, Jun 6, 2011
  4. 3/3 Windows: teach getenv to do a case-sensitive searchJohannes Sixt, Jun 6, 2011
  5. Karsten BleesOct 5, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.