https://bugs.winehq.org/show_bug.cgi?id=44369
Bug ID: 44369 Summary: cmd's %0 path variables (e.g. %~dp0) wrong inside subroutine call Product: Wine Version: 3.0-rc6 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: cmd Assignee: wine-bugs@winehq.org Reporter: ryan.prichard@gmail.com Distribution: ---
Test program (C:\bin\workaround.cmd):
@echo off call :fix exit /b :fix echo [%0] [%~d0] [%~p0] [%~n0] [%~x0] exit /b
Expected behavior (tested on XP):
C:>set PATH=C:\bin;%PATH%
C:>workaround.cmd [:fix] [C:] [\bin] [workaround] [.cmd]
C:>"workaround.cmd" [:fix] [C:] [\bin] [workaround] [.cmd]
C:>"w"or"k"aroun"d.c"md [:fix] [C:] [\bin] [workaround] [.cmd]
Behavior on wine-3.0-rc6:
c:>set PATH=C:\bin;%PATH%
c:>workaround.cmd [:fix] [c:] [] [:fix] []
c:>"workaround.cmd" [:fix] [c:] [] [:fix] []
c:>"w"or"k"aroun"d.c"md [:fix] [c:] [] [:fix] []
Background:
The Android NDK generates wrapper batch files that invoke clang.exe. If the wrapper is invoked from the PATH using double-quotes, then %~dp0 is wrong (when using Windows CMD). A workaround I've found is to evaluate %~dp0 in a subroutine in the batch file. This workaround works with Windows CMD, but breaks with Wine CMD. (It expands to the working directory instead.)
See https://github.com/android-ndk/ndk/issues/616#issuecomment-358117090.
FWIW: Wine CMD doesn't have the same %~dp0 bugginess as Windows CMD that motivated the GitHub issue I linked to. Wine handles all of the example command lines on that GitHub comment consistently (aside from case differences in the drive letter or the filename extension). If Wine tries to match Windows bug-for-bug, then maybe this too should change.