Allow empty-valued environment variables to be passed to non-MSYS programs#101
Conversation
There is a difference between an empty value and an unset environment variable. We should not confuse both; If the user wants to unset an environment variable, they can certainly do so (unsetenv(3), or in the shell: 'unset ABC'). This fixes Git's t3301-notes.sh, which overrides environment variables with empty values. Signed-off-by: Johannes Schindelin <[email protected]>
We just disabled the code that skips environment variables whose values are empty. However, this code was introduced a long time ago into Cygwin in d6b1ac7 (* environ.cc (build_env): Don't put an empty environment variable into the environment. Optimize use of "len". * errno.cc (ERROR_MORE_DATA): Translate to EMSGSIZE rather than EAGAIN., 2006-09-07), seemingly without any complaints. Meaning: There might very well be use cases out there where it makes sense to skip empty-valued environment variables. Therefore, it seems like a good idea to have a "knob" to turn it back on. With this commit, we introduce such a knob: by setting `noemptyenvvalues` the `MSYS` variable (or appending it if that variable is already set), users can tell the MSYS2 runtime to behave just like in the olden times. Signed-off-by: Johannes Schindelin <[email protected]>
With this commit, you can call MSYS=noemptyenvvalues my-command and it does what is expected: to pass no empty-valued environment variables to `my-command`. Signed-off-by: Johannes Schindelin <[email protected]>
cab134e to
013b43a
Compare
Why without the escape hatch? But yes, my answer is: yes, I think we should upstream this. |
if no one knows why it was added and if there is no fallout in MSYS2 then it seems like unnecessary complexity. we'll see.... |
Well, the original behavior (to treat environment variables with empty values as if they were deleted) hails from Cygwin, not from MSYS2... So they would know (or should know) why it was added. |
This integrates the patches from msys2/msys2-runtime#102 and from msys2/msys2-runtime#101 Signed-off-by: Johannes Schindelin <[email protected]>
|
There is some fallout from this, some fixable, some I don't understand yet. We currently have CPython in MSYS2 mode if "MSYSTEM" isn't set and in various examples we just do "MSYSTEM= python" because up until now this just happened to remove the env var I guess. That would be fixable by users by changing the code to $ unset MSYSTEM
$ env | grep MSYSTEM=
MSYSTEM=MINGW64So, the Python thing we can likely fix in MSYS2 by also recognizing an empty MSYSTEM env var in CPython -> msys2-contrib/cpython-mingw#107 Any ideas why unset doesn't work here? |
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched.
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched.
I'll open issues for anything else that comes up. |
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched.
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched.
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched.
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched.
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
… one Up until now this didn't really happen when calling from cygwin because empty env vars were removed before Python would run. But msys2/msys2-runtime#101 changed that. To avoid breaking users that did something like MSYSTEM= python ... not only check that MSYSTEM isn't set but also that it isn't empty when deciding if os.sep/os.altsep should be switched. Also, guard the msystem env check to execute only on MINGW Co-authored-by: Naveen M K <[email protected]>
This addresses #99 and also reduces the difference between the MSYS2 runtime and Git for Windows' fork of the same.