Skip to content

Commit 5194fb9

Browse files
committed
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 <[email protected]>
1 parent b03e6f9 commit 5194fb9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

winsup/cygwin/environ.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,11 +1326,11 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
13261326
Note that this doesn't stop invalid strings without '=' in it
13271327
etc., but we're opting for speed here for now. Adding complete
13281328
checking would be pretty expensive. */
1329-
if (len == 1 || !*rest)
1329+
if (len == 1)
13301330
continue;
13311331

13321332
/* See if this entry requires posix->win32 conversion. */
1333-
conv = getwinenv (*srcp, rest, &temp);
1333+
conv = !*rest ? NULL : getwinenv (*srcp, rest, &temp);
13341334
if (conv)
13351335
{
13361336
p = conv->native; /* Use win32 path */
@@ -1344,7 +1344,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
13441344
}
13451345
}
13461346
#ifdef __MSYS__
1347-
else if (!keep_posix) {
1347+
else if (!keep_posix && *rest) {
13481348
char *win_arg = arg_heuristic_with_exclusions
13491349
(*srcp, msys2_env_conv_excl_env, msys2_env_conv_excl_count);
13501350
debug_printf("WIN32_PATH is %s", win_arg);

0 commit comments

Comments
 (0)