Skip to content

Commit 3e9c003

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 <johannes.schindelin@gmx.de>
1 parent 589fac6 commit 3e9c003

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
@@ -1339,11 +1339,11 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
13391339
Note that this doesn't stop invalid strings without '=' in it
13401340
etc., but we're opting for speed here for now. Adding complete
13411341
checking would be pretty expensive. */
1342-
if (len == 1 || !*rest)
1342+
if (len == 1)
13431343
continue;
13441344

13451345
/* See if this entry requires posix->win32 conversion. */
1346-
conv = getwinenv (*srcp, rest, &temp);
1346+
conv = !*rest ? NULL : getwinenv (*srcp, rest, &temp);
13471347
if (conv)
13481348
{
13491349
p = conv->native; /* Use win32 path */
@@ -1357,7 +1357,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
13571357
}
13581358
}
13591359
#ifdef __MSYS__
1360-
else if (!keep_posix) {
1360+
else if (!keep_posix && *rest) {
13611361
char *win_arg = arg_heuristic_with_exclusions
13621362
(*srcp, msys2_env_conv_excl_env, msys2_env_conv_excl_count);
13631363
debug_printf("WIN32_PATH is %s", win_arg);

0 commit comments

Comments
 (0)