Commit 5e2f9996 authored by Maarten De Braekeleer's avatar Maarten De Braekeleer Committed by Alexandre Julliard

cmd: Fix 'if exist' with a directory/ as a parameter.

'if exists' takes a parameter which can be directory, directory/, directory/. directory\ or directory\. for example, and should equate to true if the directory exists. The syntax directory\ is explicitly rejected by FindFirstFile and hence was not working - look for this specific case, and if found append a '.'. Follow-up commit of bc9d68bc Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55130#add_comment
parent dcf0bf1f
......@@ -2844,8 +2844,8 @@ int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate)
int len = lstrlenW(param);
if (!len) goto syntax_err;
/* FindFirstFile does not like a directory path ending in '\', append a '.' */
if (param[len-1] == '\\') lstrcatW(param, L".");
/* FindFirstFile does not like a directory path ending in '\' or '/', append a '.' */
if (param[len-1] == '\\' || param[len-1] == '/') lstrcatW(param, L".");
hff = FindFirstFileW(param, &fd);
*test = (hff != INVALID_HANDLE_VALUE );
......
......@@ -1138,9 +1138,9 @@ if exist subdir (
echo ERROR exist subdir not working
)
if exist subdir\. (
echo exist subdir with . ok
echo exist subdir with \. ok
) else (
echo ERROR exist subdir with . not working
echo ERROR exist subdir with \. not working
)
if exist subdir\ (
echo exist subdir with \ ok
......@@ -1152,6 +1152,21 @@ if exist "subdir\" (
) else (
echo ERROR exist subdir with \ and quotes not working
)
if exist subdir/. (
echo exist subdir with /. ok
) else (
echo ERROR exist subdir with /. not working
)
if exist subdir/ (
echo exist subdir with / ok
) else (
echo ERROR exist subdir with / not working
)
if exist "subdir/" (
echo exist subdir with / and quotes ok
) else (
echo ERROR exist subdir with / and quotes not working
)
del foo subdir\bar
rd subdir
......
......@@ -821,9 +821,12 @@ exist wildcard works
negate exist wildcard works
exist wildcard bad subdir broken works
exist subdir ok
exist subdir with . ok
exist subdir with \. ok
exist subdir with \ ok
exist subdir with \ and quotes ok
exist subdir with /. ok
exist subdir with / ok
exist subdir with / and quotes ok
------ 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