Skip to content

Commit

Permalink
Handle ORIGINAL_PATH just like PATH
Browse files Browse the repository at this point in the history
MSYS2 recently introduced that hack where the ORIGINAL_PATH variable is
set to the original PATH value in /etc/profile, unless previously set.
In Git for Windows' default mode, that ORIGINAL_PATH value is the used
to define the PATH variable explicitly.

So far so good.

The problem: when calling from inside an MSYS2 process (such as Bash) a
MINGW executable (such as git.exe) that then calls another MSYS2
executable (such as bash.exe), that latter call will try to re-convert
ORIGINAL_PATH after the previous call converted ORIGINAL_PATH from POSIX
to Windows paths. And this conversion may very well fail, e.g. when the
path list contains mixed semicolons and colons.

So let's just *force* the MSYS2 runtime to handle ORIGINAL_PATH in the
same way as the PATH variable (which conversion works, as we know).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Feb 27, 2024
1 parent c90f0a9 commit 4f0efbc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion winsup/cygwin/environ.cc
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ static win_env conv_envvars[] =
{NL ("HOME="), NULL, NULL, env_path_to_posix, env_path_to_win32, false},
{NL ("LD_LIBRARY_PATH="), NULL, NULL,
env_plist_to_posix, env_plist_to_win32, true},
{NL ("ORIGINAL_PATH="), NULL, NULL, env_PATH_to_posix, env_plist_to_win32, true},
{NL ("SHELL="), NULL, NULL, env_path_to_posix, env_path_to_win32, true, true},
{NL ("TMPDIR="), NULL, NULL, env_path_to_posix, env_path_to_win32, false},
{NL ("TMP="), NULL, NULL, env_path_to_posix, env_path_to_win32, false},
Expand All @@ -349,7 +350,7 @@ static const unsigned char conv_start_chars[256] =
0, 0, 0, 0, 0, 0, 0, 0,
/* 72 */
/* H I J K L M N O */
WC, 0, 0, 0, WC, 0, 0, 0,
WC, 0, 0, 0, WC, 0, 0, WC,
/* 80 */
/* P Q R S T U V W */
WC, 0, 0, WC, WC, 0, 0, 0,
Expand Down

0 comments on commit 4f0efbc

Please sign in to comment.