Commit 859d5e68 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

cmd: Handle `if exist` with an empty string argument.

parent 61c5d2a0
......@@ -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);
}
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment