Module: wine
Branch: master
Commit: bc9d68bcbee5c9d4f4582f766a4f552870385361
URL: https://source.winehq.org/git/wine.git/?a=commit;h=bc9d68bcbee5c9d4f4582f76…
Author: Jason Edmeades <us(a)edmeades.me.uk>
Date: Mon Aug 27 20:41:52 2018 +0100
cmd: Fix 'if exist' with a directory\ as a parameter.
'if exists' takes a parameter which can be 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 '.'.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45506
Signed-off-by: Jason Edmeades <us(a)edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
programs/cmd/builtins.c | 9 ++++++++-
programs/cmd/tests/test_builtins.cmd | 20 ++++++++++++++++++++
programs/cmd/tests/test_builtins.cmd.exp | 4 ++++
3 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index cb4a7b9..25d5be1 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -2861,7 +2861,14 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList)
}
else if (!lstrcmpiW (condition, existW)) {
WIN32_FIND_DATAW fd;
- HANDLE hff = FindFirstFileW(WCMD_parameter(p, 1+negate, NULL, FALSE, FALSE), &fd);
+ HANDLE hff;
+ WCHAR *param = WCMD_parameter(p, 1+negate, NULL, FALSE, FALSE);
+ int len = strlenW(param);
+
+ /* FindFirstFile does not like a directory path ending in '\', append a '.' */
+ if (len && param[len-1] == '\\') strcatW(param, dotW);
+
+ hff = FindFirstFileW(param, &fd);
test = (hff != INVALID_HANDLE_VALUE );
if (test) FindClose(hff);
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index 0e88ad1..b36afa4 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -1046,6 +1046,26 @@ if exist idontexist\ba* (
) else (
echo exist wildcard bad subdir broken works
)
+if exist subdir (
+ echo exist subdir ok
+) else (
+ echo ERROR exist subdir 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
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 1f2b5dd..764e454 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -783,6 +783,10 @@ exist simple wildcard works
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 \ and quotes ok
------ for numbers
negative numbers handled
negative numbers handled
Module: wine
Branch: master
Commit: 8b6ba774c0ef5f25e1dfd314d870b16f60dce2b6
URL: https://source.winehq.org/git/wine.git/?a=commit;h=8b6ba774c0ef5f25e1dfd314…
Author: Jason Edmeades <us(a)edmeades.me.uk>
Date: Mon Aug 27 20:41:51 2018 +0100
cmd: for /f fails to launch quoted program plus args.
for /f can run a program and parse its output. The program name can
supply args and be quoted or not. If quoted, wine fails to run the
program because internally we were adding an extra pair of
quotes. These are not needed and can be removed.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=39906
Signed-off-by: Jason Edmeades <us(a)edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
programs/cmd/builtins.c | 2 +-
programs/cmd/tests/test_builtins.cmd | 4 +++-
programs/cmd/tests/test_builtins.cmd.exp | 2 ++
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 5026f9c..cb4a7b9 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -2073,7 +2073,7 @@ static HANDLE WCMD_forf_getinputhandle(BOOL usebackq, WCHAR *itemstr, BOOL iscmd
static const WCHAR redirOutW[] = {'>','%','s','\0'};
static const WCHAR cmdW[] = {'C','M','D','\0'};
static const WCHAR cmdslashcW[] = {'C','M','D','.','E','X','E',' ',
- '/','C',' ','"','%','s','"','\0'};
+ '/','C',' ','%','s','\0'};
/* Remove leading and trailing character */
if ((iscmd && (itemstr[0] == '`' && usebackq)) ||
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd
index 0738f2d..0e88ad1 100644
--- a/programs/cmd/tests/test_builtins.cmd
+++ b/programs/cmd/tests/test_builtins.cmd
@@ -1724,9 +1724,11 @@ if "%CD%"=="" goto :SkipFORFcmdNT4
for /f %%i in ('echo.Passed1') do echo %%i
for /f "usebackq" %%i in (`echo.Passed2`) do echo %%i
for /f usebackq %%i in (`echo.Passed3`) do echo %%i
+for /f "usebackq" %%i in (`"c:\windows\system32\cmd.exe" /C echo Passed4`) do echo %%i
+for /f "usebackq" %%i in (`""c:\windows\system32\cmd.exe" /C echo Passed5"`) do echo %%i
goto :ContinueFORF
:SkipFORFcmdNT4
-for /l %%i in (1,1,3) do echo Missing functionality - Broken%%i
+for /l %%i in (1,1,5) do echo Missing functionality - Broken%%i
:ContinueFORF
rem FIXME: Rest not testable right now in wine: not implemented and would need
rem preliminary grep-like program implementation (e.g. like findstr or fc) even
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index 7ec83d7..1f2b5dd 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -1209,6 +1209,8 @@ c
Passed1@or_broken@Missing functionality - Broken1
Passed2@or_broken@Missing functionality - Broken2
Passed3@or_broken@Missing functionality - Broken3
+Passed4@or_broken@Missing functionality - Broken4
+Passed5@or_broken@Missing functionality - Broken5
------ eol option
and@or_broken@Broken NT4 functionality1
Line@or_broken@Broken NT4 functionality2
Module: wine
Branch: master
Commit: 58d21b3319f719b4d0b6972a801b5f81993d5c10
URL: https://source.winehq.org/git/wine.git/?a=commit;h=58d21b3319f719b4d0b6972a…
Author: Jason Edmeades <us(a)edmeades.me.uk>
Date: Mon Aug 27 20:41:50 2018 +0100
cmd: Handle single line 'if' as nested if or with redirects.
A single line if statement causes problems when it has redirects
and/or continuation type operators (|, &&, || etc) because it is
expected that if there is more than one command in the 'if', then it
will use brackets. This patch changes the 'if' parsing to emulate
brackets at a continuation character. In addition, 'for' and 'if'
statements do not have their output redirected immediately, instead it
is redirected on the individual commands being executed not the
statement itself. We were opening the redirect once for the 'if' and
once for the processing of the statement inside the if.
Signed-off-by: Jason Edmeades <us(a)edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
programs/cmd/builtins.c | 16 +-
programs/cmd/tests/test_builtins.cmd | 9 +
programs/cmd/tests/test_builtins.cmd.exp | 7 +-
programs/cmd/wcmdmain.c | 309 +++++++++++++++++--------------
4 files changed, 200 insertions(+), 141 deletions(-)
Diff: https://source.winehq.org/git/wine.git/?a=commitdiff;h=58d21b3319f719b4d0b6…
Module: wine
Branch: master
Commit: 5c444c4e0dd51e824468d78215f795d67632ea49
URL: https://source.winehq.org/git/wine.git/?a=commit;h=5c444c4e0dd51e824468d782…
Author: Jason Edmeades <us(a)edmeades.me.uk>
Date: Mon Aug 27 20:41:49 2018 +0100
cmd: Fix shortpath handling in for loops.
When 's' is used as a modifier, the paths that are presented to the
other modifiers needs to be a short path. Given the 'filename' part of
the path may not exist, we cannot use GetShortPathName directly
without first removing the filename part to just leave the directory
bit.
Signed-off-by: Jason Edmeades <us(a)edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
programs/cmd/batch.c | 17 +++++++++++++----
programs/cmd/tests/test_builtins.cmd.exp | 12 ++++++------
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/programs/cmd/batch.c b/programs/cmd/batch.c
index 14e2539..1ed5197 100644
--- a/programs/cmd/batch.c
+++ b/programs/cmd/batch.c
@@ -399,6 +399,7 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
WCHAR finaloutput[MAX_PATH];
WCHAR fullfilename[MAX_PATH];
WCHAR thisoutput[MAX_PATH];
+ WCHAR *filepart = NULL;
WCHAR *pos = *start+1;
WCHAR *firstModifier = pos;
WCHAR *lastModifier = NULL;
@@ -522,7 +523,7 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
/* After this, we need full information on the file,
which is valid not to exist. */
if (!skipFileParsing) {
- if (GetFullPathNameW(outputparam, MAX_PATH, fullfilename, NULL) == 0) {
+ if (GetFullPathNameW(outputparam, MAX_PATH, fullfilename, &filepart) == 0) {
exists = FALSE;
fullfilename[0] = 0x00;
} else {
@@ -598,8 +599,16 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
/* 4. Handle 's' : Use short paths (File doesn't have to exist) */
if (memchrW(firstModifier, 's', modifierLen) != NULL) {
if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW);
- /* Don't flag as doneModifier - %~s on its own is processed later */
- GetShortPathNameW(outputparam, outputparam, ARRAY_SIZE(outputparam));
+
+ /* Convert fullfilename's path to a short path - Save filename away as
+ only path is valid, name may not exist which causes GetShortPathName
+ to fail if it is provided */
+ if (filepart) {
+ strcpyW(thisoutput, filepart);
+ *filepart = 0x00;
+ GetShortPathNameW(fullfilename, fullfilename, ARRAY_SIZE(fullfilename));
+ strcatW(fullfilename, thisoutput);
+ }
}
/* 5. Handle 'f' : Fully qualified path (File doesn't have to exist) */
@@ -673,7 +682,7 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
memchrW(firstModifier, 's', modifierLen) != NULL) {
doneModifier = TRUE;
if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW);
- strcatW(finaloutput, outputparam);
+ strcatW(finaloutput, fullfilename);
}
}
}
diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp
index ea4157c..35e0cf2 100644
--- a/programs/cmd/tests/test_builtins.cmd.exp
+++ b/programs/cmd/tests/test_builtins.cmd.exp
@@ -530,9 +530,9 @@ N
'.OOL'
'.TABC'
''
-@todo_wine@'@drive@@shortpath@R S'@or_broken@''
-@todo_wine@'@drive@@shortpath@T'@or_broken@''
-@todo_wine@'@drive@@shortpath@ABCDEFGHIJK.LMNOP'@or_broken@''
+'@drive@@shortpath@R S'@or_broken@''
+'@drive@@shortpath@T'@or_broken@''
+'@drive@@shortpath@ABCDEFGHIJK.LMNOP'@or_broken@''
''@or_broken@'%~ai'
''@or_broken@'%~ai'
'--a------'@or_broken@'--a--------'@or_broken@'--a--c---'@or_broken@'%~ai'
@@ -566,9 +566,9 @@ N
'.OOL'
'.TABC'
''
-@todo_wine@'@drive@@shortpath@R S'@or_broken@''
-@todo_wine@'@drive@@shortpath@T'@or_broken@''
-@todo_wine@'@drive@@shortpath@ABCDEFGHIJK.LMNOP'@or_broken@''
+'@drive@@shortpath@R S'@or_broken@''
+'@drive@@shortpath@T'@or_broken@''
+'@drive@@shortpath@ABCDEFGHIJK.LMNOP'@or_broken@''
@drive@@path@
@drive@@path@
@drive@