Skip to content

Allow empty-valued environment variables to be passed to non-MSYS programs#101

Merged
dscho merged 3 commits into
msys2:msys2-3_3_6-releasefrom
dscho:allow-empty-env-values
Sep 20, 2022
Merged

Allow empty-valued environment variables to be passed to non-MSYS programs#101
dscho merged 3 commits into
msys2:msys2-3_3_6-releasefrom
dscho:allow-empty-env-values

Conversation

@dscho

@dscho dscho commented Sep 6, 2022

Copy link
Copy Markdown
Collaborator

This addresses #99 and also reduces the difference between the MSYS2 runtime and Git for Windows' fork of the same.

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]>
@dscho
dscho force-pushed the allow-empty-env-values branch from cab134e to 013b43a Compare September 6, 2022 10:20
@dscho dscho self-assigned this Sep 6, 2022
@dscho
dscho marked this pull request as ready for review September 6, 2022 11:57
@dscho
dscho requested review from jeremyd2019 and lazka September 6, 2022 11:57

@lazka lazka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

just wondering, do you think if this turns out to not make any problems (after some time) could we propose it to cygwin without the escape hatch?

@dscho

dscho commented Sep 20, 2022

Copy link
Copy Markdown
Collaborator Author

do you think if this turns out to not make any problems (after some time) could we propose it to cygwin without the escape hatch?

Why without the escape hatch?

But yes, my answer is: yes, I think we should upstream this.

@lazka

lazka commented Sep 20, 2022

Copy link
Copy Markdown
Member

Why without the escape hatch?

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....

@dscho

dscho commented Sep 20, 2022

Copy link
Copy Markdown
Collaborator Author

Why without the escape hatch?

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.

@lazka

lazka commented Sep 22, 2022

Copy link
Copy Markdown
Member

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, but for some reason that doesn't work (likely didn't work before as well?):

$ unset MSYSTEM
$ env | grep MSYSTEM=
MSYSTEM=MINGW64

So, 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?

lazka added a commit to lazka/cpython that referenced this pull request Sep 22, 2022
… 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.
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Sep 23, 2022
… 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.
@lazka

lazka commented Sep 23, 2022

Copy link
Copy Markdown
Member

I'll open issues for anything else that comes up.

lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Oct 15, 2022
… 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.
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Oct 15, 2022
… 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.
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Dec 8, 2022
… 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.
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Dec 9, 2022
… 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.
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Jul 19, 2023
… 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]>
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Jul 19, 2023
… 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]>
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Aug 25, 2023
… 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]>
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Aug 27, 2023
… 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]>
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Oct 2, 2023
… 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]>
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Oct 2, 2023
… 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]>
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Dec 6, 2023
… 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]>
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Dec 7, 2023
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Jan 1, 2024
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Jan 1, 2024
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Jan 1, 2024
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Jan 1, 2024
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Jan 1, 2024
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Jan 1, 2024
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Jan 1, 2024
… 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]>
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Feb 10, 2024
… 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]>
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Feb 12, 2024
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Feb 19, 2024
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Feb 19, 2024
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Feb 19, 2024
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Feb 21, 2024
… 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]>
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Apr 11, 2024
… 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]>
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Apr 12, 2024
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Jul 11, 2024
… 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]>
naveen521kk added a commit to msys2-contrib/cpython-mingw that referenced this pull request Aug 5, 2024
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Sep 4, 2024
… 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]>
naveen521kk added a commit to naveen521kk/cpython that referenced this pull request Sep 9, 2024
… 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]>
naveen521kk added a commit to msys2-contrib/cpython-mingw that referenced this pull request Sep 9, 2024
… 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]>
lazka added a commit to msys2-contrib/cpython-mingw that referenced this pull request Sep 10, 2024
… 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants