https://bugs.winehq.org/show_bug.cgi?id=57137
Bug ID: 57137 Summary: endlocal changes CWD if pushd/popd are called before Product: Wine Version: 9.16 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: cmd Assignee: wine-bugs@winehq.org Reporter: huangqinjin@gmail.com Distribution: ---
Run test.bat, got output
Z:\home Z:\home\huangqinjin Z:\home
test.bat:
@echo off
pushd "%~dp0.." cd popd
setlocal cd endlocal cd
https://bugs.winehq.org/show_bug.cgi?id=57137
huangqinjin huangqinjin@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|endlocal changes CWD if |startlocal/endlocal changes |pushd/popd are called |CWD if pushd/popd are |before |called before
https://bugs.winehq.org/show_bug.cgi?id=57137
Ken Sharp imwellcushtymelike@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |source, testcase
https://bugs.winehq.org/show_bug.cgi?id=57137
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download
https://bugs.winehq.org/show_bug.cgi?id=57137
Eric Pouech eric.pouech@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |eric.pouech@gmail.com
--- Comment #1 from Eric Pouech eric.pouech@gmail.com --- (not sure I'm going to work on this in the short term; so writing some notes if someone is willing to look into it)
that will require more testing to investigate the impact on internal structures...
some quick look: - current directory for all drives is saved by setlocal on windows (not only current one) - and all drives are restored by endlocal (on windows)
I don't think tweaking the setlocal/endlocal structure to store all drives as dedicated fields is the correct approach IMO, we should rather use the =<Drive>: env variables; they are partly supported in builtin cmd, but will likely need more work...
Indication: 'echo %=c:%' on native shows the default dir for drive C (doesn't work yet on builtin) (see [1] for more details)
likely to be assessed (non exhaustive list): - how are the env variables inherited/created on cmd.exe creation (wild guess: inherited when they exist, and set to =<drive>:=\ when not present at startup) - how they are passed to child process (wild guess: simply passed as part of current env) - impact on CD/CHDIR builtin commands (wild guess: likely update env var accordingly, partly done, requires some more tests) - likely low impact on the rest of the code as RtlGetFullPathName_U already handles them
-Eric
[1] https://devblogs.microsoft.com/oldnewthing/20100506-00/?p=14133