MSYS2-packages/msys2-runtime-3.4/0032-Pass-environment-variables-with-empty-values.patch
2022-12-11 14:01:08 +01:00

46 lines
1.7 KiB
Diff

From 59b6d44bc001b07793310a885424c203a8ff2cfb Mon Sep 17 00:00:00 2001
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Date: Wed, 18 Feb 2015 12:32:17 +0000
Subject: [PATCH 32/N] Pass environment variables with empty values
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 <johannes.schindelin@gmx.de>
---
winsup/cygwin/environ.cc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index ffb1d5e..0152095 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -1325,11 +1325,11 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
Note that this doesn't stop invalid strings without '=' in it
etc., but we're opting for speed here for now. Adding complete
checking would be pretty expensive. */
- if (len == 1 || !*rest)
+ if (len == 1)
continue;
/* See if this entry requires posix->win32 conversion. */
- conv = getwinenv (*srcp, rest, &temp);
+ conv = !*rest ? NULL : getwinenv (*srcp, rest, &temp);
if (conv)
{
p = conv->native; /* Use win32 path */
@@ -1343,7 +1343,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
}
}
#ifdef __MSYS__
- else if (!keep_posix) {
+ else if (!keep_posix && *rest) {
char *win_arg = arg_heuristic_with_exclusions
(*srcp, msys2_env_conv_excl_env, msys2_env_conv_excl_count);
debug_printf("WIN32_PATH is %s", win_arg);