Skip to content

Commit

Permalink
fixup! Pass environment variables with empty values
Browse files Browse the repository at this point in the history
The patch was incomplete. It resulted in settings like `SHELL=` to
*skip* the variable name and the equal sign and instead insert a NUL,
i.e. instead of putting `SHELL=\0` into the environment block, it would
append `\0\0` which would be interpreted as the end of the environment
block instead.

Funnily enough, this was only noticed years later, when Git's `git
rebase -i` progress was changed to clear the line differently depending
on the `TERM` setting, and t/t3404-rebase-interactive.sh triggered the
bug by setting `SHELL` to the empty value, which due to the bug fixed
here would drop `TERM=dumb` by mistake.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Jun 14, 2019
1 parent dec9bcc commit c10b418
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions winsup/cygwin/environ.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
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 @@ -1337,7 +1337,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 c10b418

Please sign in to comment.