http://bugs.winehq.org/show_bug.cgi?id=21047
Summary: cmd does not handle for %%a in ('command') Product: Wine Version: 1.1.34 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: programs AssignedTo: wine-bugs@winehq.org ReportedBy: dank@kegel.com
an example in bug 15359 shows that firefox's build script relies on cmd being able to loop over the output of another command using the for command:
FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "%MSVC6KEY%" /v ProductDir') DO SET VC6DIR=%%B
Similar behavior is documented at http://technet.microsoft.com/en-us/library/bb490909.aspx but there it uses the /f option usebackq, and uses backquotes rather than single quotes?
http://bugs.winehq.org/show_bug.cgi?id=21047
Dan Kegel dank@kegel.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|programs |cmd
http://bugs.winehq.org/show_bug.cgi?id=21047
Dan Kegel dank@kegel.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|cmd does not handle for %%a |cmd does not handle FOR /F |in ('command') |%%a in ('command') properly
--- Comment #1 from Dan Kegel dank@kegel.com 2010-01-06 15:12:10 --- Simple test: a batch file foo.cmd containing for /f %%a in ('echo a b c') do echo %%a should output a
That's supposed to work in wine already, but doesn't seem to. http://source.winehq.org/source/programs/cmd/builtins.c#L888
Here's what one sees with WINEDEBUG=+cmd,+process wine cmd /c foo.cmd ... trace:cmd:WCMD_for Processing for filespec from item 1 'L"'echo"' trace:cmd:WCMD_execute command on entry:L"'echo a b c" ((nil)), with '(null)'='(null)' trace:cmd:WCMD_execute Redirect 1 to 'L"echo"' (0x44) trace:cmd:WCMD_execute Command: 'L"'echo a b c"' trace:cmd:WCMD_execute param1: L"'echo", param2: L"a" trace:cmd:WCMD_run_program Searching in 'L".;C:\windows\system32;C:\windows"' for 'L"'echo"' trace:cmd:WCMD_run_program Found as L"Z:\data\dkegel\wine-git\'echo.*" trace:cmd:WCMD_run_program Found as L"C:\windows\system32\'echo.*" trace:cmd:WCMD_run_program ASSUMING INTERNAL trace:process:CreateProcessW app (null) cmdline L"'echo a b c" ... trace:process:find_exe_file Trying built-in exe L"C:\windows\system32\'echo a b c.exe" File not found
See also http://ss64.com/nt/for_cmd.html and http://ss64.com/nt/for_f.html
http://bugs.winehq.org/show_bug.cgi?id=21047
--- Comment #2 from Jason Edmeades us@edmeades.me.uk 2010-01-06 17:04:20 --- Created an attachment (id=25593) --> (http://bugs.winehq.org/attachment.cgi?id=25593) Fixes basic case
This will fix the basic case listed in the comment (where command is eg. 'echo a b c') but will not solve the reported problem.
There are 2 halfs to solve the reported problem and support for /F better: 1. You need to convert the 'delims' if supplied into a parameter passed into WCMD_parameter, and all other callers should use the default (whitespace) - Without this the reported problem would work but other simple for /F commands will fail
2. tokens needs supporting - currently we assume the first thing on the line is the only token, but we need to support eg. 1,3,4* which means 1st, 3rd and 4th 'parameter' gets mapped to variable name, variable name+1, variable name+2, and +3 for the rest (eg for /F "tokens=1,3,4*" %a in ('echo a b c d e f g') do echo %a %b %c rest:%d blank:%e)
Feel free to add a test when you get the test infrastructure in, and submit the patch / clean it up
http://bugs.winehq.org/show_bug.cgi?id=21047
Jason Edmeades us@edmeades.me.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |us@edmeades.me.uk
--- Comment #3 from Jason Edmeades us@edmeades.me.uk 2010-01-06 18:26:41 --- Adding myself to the cmd bugs
http://bugs.winehq.org/show_bug.cgi?id=21047
Trey Hunner treyhunner@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |treyhunner@gmail.com
http://bugs.winehq.org/show_bug.cgi?id=21047
Magnus Bergman magnus.bergman@jamtli.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |magnus.bergman@jamtli.com
--- Comment #4 from Magnus Bergman magnus.bergman@jamtli.com 2010-03-18 09:36:50 --- A related problem (which might be connected) is that "for /d" works slightly different in wine (1.1.35) compared to windows. The following example prints all directories in the root of c:
for /d %%g in (c:*.*) do echo %%g
With wine only the directory names are prinded (like "Program Files") but in windows the whole paths are prinded (like "c:\Program Files"). This should probably be considered a bug and the windows behavior should be adopted.
http://bugs.winehq.org/show_bug.cgi?id=21047
--- Comment #5 from Austin English austinenglish@gmail.com 2010-03-18 11:13:54 --- (In reply to comment #4)
A related problem (which might be connected) is that "for /d" works slightly different in wine (1.1.35) compared to windows. The following example prints all directories in the root of c:
for /d %%g in (c:*.*) do echo %%g
With wine only the directory names are prinded (like "Program Files") but in windows the whole paths are prinded (like "c:\Program Files"). This should probably be considered a bug and the windows behavior should be adopted.
Please file a new bug for this.
http://bugs.winehq.org/show_bug.cgi?id=21047
Juan Lang juan_lang@yahoo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |nerv@dawncrow.de
--- Comment #6 from Juan Lang juan_lang@yahoo.com 2010-09-08 11:38:30 CDT --- *** Bug 24300 has been marked as a duplicate of this bug. ***
http://bugs.winehq.org/show_bug.cgi?id=21047
--- Comment #7 from André H. nerv@dawncrow.de 2010-11-09 16:31:59 CST --- (In reply to comment #2)
Created an attachment (id=25593)
--> (http://bugs.winehq.org/attachment.cgi?id=25593) [details]
Feel free to add a test when you get the test infrastructure in, and submit the patch / clean it up
It seems noone here can/want do it, so can you please have a look at it again? BTW: Your patch already helped me with Android SDK...
http://bugs.winehq.org/show_bug.cgi?id=21047
johnaaronrose john.aaron.rose@googlemail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |john.aaron.rose@googlemail. | |com
--- Comment #8 from johnaaronrose john.aaron.rose@googlemail.com 2011-12-22 03:09:38 CST --- (In reply to comment #7)
(In reply to comment #2)
Created an attachment (id=25593) [details] Feel free to add a test when you get the test infrastructure in, and submit the patch / clean it up
It seems noone here can/want do it, so can you please have a look at it again? BTW: Your patch already helped me with Android SDK...
I noticed that the patch helped with Android SDK. I'm trying to run Android SDK Manager under Wine but it fails due to problems (concerned with path folder names containing a space e.g. Program Files) with its batch files (find_java.bat & android.bat) . The reason for this is that I would like to use Basic4Android (only available for Windows). I noticed that you said that the patch helped you with Android SDK. Could you advise?
http://bugs.winehq.org/show_bug.cgi?id=21047
--- Comment #9 from Jason Edmeades us@edmeades.me.uk 2012-11-04 17:50:26 CST --- For reference, most of for /f has now been added over the last few weeks, except the tokens= part, which I am currently working through. If you still have a problem with for, which does not involve the tokens= field, please file a new bug report (and assign to cmd component and I'll see it).
I hope to have 'submittable' patches by next weekend, as the change to having multiple for variables in effect is proving 'interesting'
http://bugs.winehq.org/show_bug.cgi?id=21047
Jason Edmeades us@edmeades.me.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|wine-bugs@winehq.org |us@edmeades.me.uk
http://bugs.winehq.org/show_bug.cgi?id=21047
--- Comment #10 from Jason Edmeades us@edmeades.me.uk 2012-11-19 15:05:06 CST --- Patch sent: http://www.winehq.org/pipermail/wine-patches/2012-November/120067.html
http://bugs.winehq.org/show_bug.cgi?id=21047
Jason Edmeades us@edmeades.me.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |47b35d5545cd9794c299acb0417 | |ab9f2de538fb8 Status|NEW |RESOLVED Resolution| |FIXED
--- Comment #11 from Jason Edmeades us@edmeades.me.uk 2012-11-20 14:29:57 CST --- All committed - please raise any remaining issues as new bugs
http://bugs.winehq.org/show_bug.cgi?id=21047
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #12 from Alexandre Julliard julliard@winehq.org 2012-11-23 14:30:22 CST --- Closing bugs fixed in 1 5.18.