MSYS2-packages/msys2-runtime-3.5/0034-Pass-environment-variables-with-empty-values.patch
2025-04-10 10:05:41 +02:00

46 lines
1.7 KiB
Diff

From 769d1e6f9a9b90bf770d7e23c9c37892af77a733 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 34/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 031db03..6b385cd 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -1326,11 +1326,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 */
@@ -1344,7 +1344,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);