[MinGW-Users] Strange behavior of MSYS shell version 5.1.8

Back to archive index
Frank Redeker frank****@razor*****
Fri Dec 9 18:29:44 JST 2022


Hello List,

I have a strange behavior when the executing a program in a MSYS shell 
version 5.1.8. I'm on Windows 10 Version 22H2 (OS Build 19045.2251). The 
strange behavior occurs when a path is on a drive created with subst.

The following steps can be used to reproduce the behavior.

Inside a Windows CMD

C:\Users\f.redeker>subst s: "C:\Program Files\Common Files\System"
C:\Users\f.redeker>subst
S:\: => C:\Program Files\Common Files\System

Inside a shell version 5.1.8

sh-5.1$ uname -a
MSYS_NT-10.0-18362 MIMIR-W10-64 3.2.0-340.x86_64 2021-07-02 08:36 UTC 
x86_64 Msys

sh-5.1$ sh --version
GNU bash, version 5.1.8(1)-release (x86_64-pc-msys)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

sh-5.1$ realpath /s/ado/msadox.dll
/s/ado/msadox.dll

sh-5.1$ cd /s
sh-5.1$ pwd
/s

sh-5.1$ realpath ado/msadox.dll
/s/ado/msadox.dll

sh-5.1$ cd ado
sh-5.1$ pwd
/s/ado

sh-5.1$ realpath msadox.dll
/c/Program Files/Common Files/System/ado/msadox.dll

But

sh-5.1$ realpath /s/ado/sadox.dll
/s/ado/msadox.dll

Inside a shell version 4.4.19

sh-4.4$ uname -a
MSYS_NT-10.0-18362 MIMIR-W10-64 3.2.0-340.x86_64 2021-07-02 08:36 UTC 
x86_64 Msys

sh-4.4$ sh --version
GNU bash, version 4.4.19(2)-release (i686-pc-msys)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

sh-4.4$ cd /s
sh-4.4$ pwd
/s
sh-4.4$ realpath ado/msadox.dll
/s/ado/msadox.dll
sh-4.4$ cd ado
sh-4.4$ pwd
/s/ado
sh-4.4$ realpath msadox.dll
/s/ado/msadox.dll

With Process Monitor I have observed that the shell does not directly 
start the program to be executed, but first another shell. When creating 
this shell it seems that the current directory is given when 
CreateProcess is called. Here, however, not the path with the subst 
drive is used but the one to which the subst drive points. Due to this 
behavior the Windows functions (e.g. _fullpath or GetFullPathName) do 
not return the result with the subst path if not an absolute path is 
specified as input parameter.

I posted this also at stackoverflow with a screenshot of Process Monitor 
Output.

https://stackoverflow.com/questions/74729567/strange-behavior-of-msys-shell-version-5-1-8


Mit freundlichen Grüßen / Best Regards

Frank Redeker



More information about the MinGW-Users mailing list
Back to archive index