Some new tests and a fix for a bug I hit recently with cmd.exe's handling of PATH.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55097
-- v3: cmd: Fix empty-strings between PATH separators cmd/tests: Add tests for PATH separator
From: Liam Middlebrook lmiddlebrook@nvidia.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55097
Signed-off-by: Liam Middlebrook lmiddlebrook@nvidia.com
-- v3: rmdir 'folder' after test --- programs/cmd/tests/test_builtins.cmd | 23 +++++++++++++++++++++++ programs/cmd/tests/test_builtins.cmd.exp | 9 +++++++++ 2 files changed, 32 insertions(+)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 3829be50f1a..fe7bedb1362 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -3294,6 +3294,29 @@ path try2 path path=try3 path + +echo ------------ Testing PATH Evaluate ------------ +mkdir folder +echo echo I'm here! > folder\sub1.bat + +echo Test normal PATH usage +set path=%cd%\folder +call sub1.bat + +echo Test PATH usage with leading semicolon +set path=;%cd%\folder +call sub1.bat + +echo Test PATH usage with fallback path +set path=%cd%;%cd%\folder +call sub1.bat + +echo Test PATH usage with double semicolon +set path=%cd%;;%cd%\folder +call sub1.bat + +del folder\sub1.bat +rmdir folder set path=%WINE_backup_path% set WINE_backup_path=
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 437ded18000..91570a7990f 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -1680,6 +1680,15 @@ Finished PATH=original PATH=try2 PATH=try3 +------------ Testing PATH Evaluate ------------ +Test normal PATH usage +I'm here!@space@ +Test PATH usage with leading semicolon +I'm here!@space@ +Test PATH usage with fallback path +I'm here!@space@ +Test PATH usage with double semicolon +I'm here!@space@ ------------ Testing start /W ------------ start /W seems to really wait ------------ Testing changing the drive letter ----------
From: Liam Middlebrook lmiddlebrook@nvidia.com
Previously if an empty-string was encountered while parsing out PATH, cmd.exe would ignore the rest of the PATH entirely.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55097
Signed-off-by: Liam Middlebrook lmiddlebrook@nvidia.com --- programs/cmd/wcmdmain.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 022ff6637c5..de6e721b26a 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -1135,6 +1135,12 @@ void WCMD_run_program (WCHAR *command, BOOL called) else lstrcpyW(temp, thisDir + 1);
+ /* When temp is an empty string, skip over it. This needs + to be done before the expansion, because WCMD_get_fullpath + fails when given an empty string */ + if (*temp == '\0') + continue; + /* Since you can have eg. .... on the path, need to expand to full information */ if (!WCMD_get_fullpath(temp, ARRAY_SIZE(thisDir), thisDir, NULL)) return;