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) ...@@ -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); WCHAR *param = WCMD_parameter(p, 1+(*negate), NULL, FALSE, FALSE);
int len = lstrlenW(param); int len = lstrlenW(param);
if (!len) goto syntax_err; if (!len) {
/* FindFirstFile does not like a directory path ending in '\' or '/', append a '.' */ *test = FALSE;
if (param[len-1] == '\\' || param[len-1] == '/') lstrcatW(param, L"."); } 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); hff = FindFirstFileW(param, &fd);
*test = (hff != INVALID_HANDLE_VALUE ); *test = (hff != INVALID_HANDLE_VALUE);
if (*test) FindClose(hff); if (*test) FindClose(hff);
}
WCMD_parameter(p, 2+(*negate), command, FALSE, FALSE); WCMD_parameter(p, 2+(*negate), command, FALSE, FALSE);
} }
......
...@@ -1176,6 +1176,11 @@ if exist "subdir/" ( ...@@ -1176,6 +1176,11 @@ if exist "subdir/" (
) else ( ) else (
echo ERROR exist subdir with / and quotes not working 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 del foo subdir\bar
rd subdir rd subdir
......
...@@ -833,6 +833,7 @@ exist subdir with \ and quotes ok ...@@ -833,6 +833,7 @@ exist subdir with \ and quotes ok
exist subdir with /. ok exist subdir with /. ok
exist subdir with / ok exist subdir with / ok
exist subdir with / and quotes ok exist subdir with / and quotes ok
exist empty string works
------ for numbers ------ for numbers
negative numbers handled negative numbers handled
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