[Bug 44369] New: cmd's %0 path variables (e.g. %~dp0) wrong inside subroutine call

wine-bugs at winehq.org wine-bugs at winehq.org
Thu Jan 18 05:33:07 CST 2018


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 at winehq.org
          Reporter: ryan.prichard at 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.

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list