From: Alex Henrie alexhenrie24@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55505 --- programs/cmd/builtins.c | 15 +++++++++------ programs/cmd/tests/test_builtins.cmd | 5 +++++ programs/cmd/tests/test_builtins.cmd.exp | 1 + 3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 419e812103a..ca703af52ec 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -2841,13 +2841,16 @@ int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate) WCHAR *param = WCMD_parameter(p, 1+(*negate), NULL, FALSE, FALSE); int len = lstrlenW(param);
- if (!len) goto syntax_err; - /* FindFirstFile does not like a directory path ending in '' or '/', append a '.' */ - if (param[len-1] == '\' || param[len-1] == '/') lstrcatW(param, L"."); + if (!len) { + *test = FALSE; + } else { + /* FindFirstFile does not like a directory path ending in '' or '/', so append a '.' */ + if (param[len-1] == '\' || param[len-1] == '/') wcscat(param, L".");
- hff = FindFirstFileW(param, &fd); - *test = (hff != INVALID_HANDLE_VALUE ); - if (*test) FindClose(hff); + hff = FindFirstFileW(param, &fd); + *test = (hff != INVALID_HANDLE_VALUE); + if (*test) FindClose(hff); + }
WCMD_parameter(p, 2+(*negate), command, FALSE, FALSE); } diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 28b935ad521..08595933622 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -1176,6 +1176,11 @@ if exist "subdir/" ( ) else ( echo ERROR exist subdir with / and quotes not working ) +if not exist "" ( + echo exist empty string works +) else ( + echo exist empty string broken +) del foo subdir\bar rd subdir
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index 57e72a77387..85e734b048a 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -833,6 +833,7 @@ exist subdir with \ and quotes ok exist subdir with /. ok exist subdir with / ok exist subdir with / and quotes ok +exist empty string works ------ for numbers negative numbers handled negative numbers handled