Skip to content

Commit

Permalink
Pass environment variables with empty values
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dscho authored and lazka committed Aug 25, 2024
1 parent 5e28622 commit dacdc1a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions winsup/cygwin/environ.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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);
Expand Down

0 comments on commit dacdc1a

Please sign in to comment.