http://bugs.winehq.org/show_bug.cgi?id=27741
Summary: Imbricated for loops parameters not expanded correctly Product: Wine Version: 1.3.24 Platform: All OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: cmd AssignedTo: wine-bugs@winehq.org ReportedBy: frederic.delanoy@gmail.com
Created an attachment (id=35491) --> (http://bugs.winehq.org/attachment.cgi?id=35491) +cmd log
Say your test_builtins.cmd looks like
@echo off for %%i in (A) do ( for %%j in (A) do ( call :myFun %%i %%j ))
goto :end :myFun echo %1 %2 goto :eof :end
and the test_builtins.cmd.exp contains "A A" as only line.
Then a test run gives:
batch.c:205: Test failed: unexpected char 0x69 position 0 in line 1 (got 'i A', wanted 'A A')
http://bugs.winehq.org/show_bug.cgi?id=27741
Frédéric Delanoy frederic.delanoy@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, source, testcase
http://bugs.winehq.org/show_bug.cgi?id=27741
--- Comment #1 from Frédéric Delanoy frederic.delanoy@gmail.com 2011-07-10 02:53:11 CDT --- @echo off for %%i in (X) do ( for %%j in (Y) do ( call :myFun %%i %%j ))
gives "%i Y" instead of "X Y"
http://bugs.winehq.org/show_bug.cgi?id=27741
--- Comment #2 from Frédéric Delanoy frederic.delanoy@gmail.com 2011-07-10 02:55:07 CDT --- (In reply to comment #1)
@echo off for %%i in (X) do ( for %%j in (Y) do ( call :myFun %%i %%j ))
gives "%i Y" instead of "X Y"
Hmm... bad copy paste earlier, it should be
@echo off for %%i in (X) do ( for %%j in (Y) do ( echo %%i %%j ))
gives "%i Y" instead of "X Y"
http://bugs.winehq.org/show_bug.cgi?id=27741
--- Comment #3 from Frédéric Delanoy frederic.delanoy@gmail.com 2011-07-12 14:54:14 CDT --- Tests integrated: http://source.winehq.org/git/wine.git/commitdiff/63a6a80d40a107f734b8a0c8617...
http://bugs.winehq.org/show_bug.cgi?id=27741
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Platform|All |Other
--- Comment #4 from Austin English austinenglish@gmail.com 2012-02-23 15:27:04 CST --- Removing deprecated 'All' Platform.
http://bugs.winehq.org/show_bug.cgi?id=27741
Jason Edmeades us@edmeades.me.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |us@edmeades.me.uk
--- Comment #5 from Jason Edmeades us@edmeades.me.uk 2012-11-04 18:23:31 CST --- 99% of this will be fixed when I get my fix for 21047 in (all todos were I think)
The problem is I have one case I cannot see how to resolve at present, and its an extreme corner case which I think is best left waiting for a real life usecase (other than a todo in tests) is for %a in.... for %a in .... When reading the 2nd line, wine finds the %a and helpfully expands it, meaning the for loop logic doesnt find a variable anymore. No idea how windows does this, other than not expanding anything after a 'for'...
It does expand the rest on the line, e.g. the %%a in the brackets is correctly expanded: for %%a in ("foobar") do ( echo %%a for %%a in (%%a) do ( echo %%a ) )
Something like the following (yes, I am warped at times) doesnt work in windows: for /f "delims=:" %%a in ("in (jason) do echo %%b") do ( echo %%a for %%b %%a )
So I think windows see's a line starting with for, and does special processing / no expanding until it gets beyond the first '('. More testing/experimenting, but wanted to document findings so far.
I have very strong suspicions that for (at least, possibly 'if' too) has special, individual parsing which might explain why this happens - for example you cannot 'call' a for loop, and whilst the following works for echo, it doesnt work for a 'for' loop... "for %a in (echo.hello) do %a"
http://bugs.winehq.org/show_bug.cgi?id=27741
Bruno Jesus 00cpxxx@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |00cpxxx@gmail.com
--- Comment #6 from Bruno Jesus 00cpxxx@gmail.com 2012-11-06 16:16:35 CST --- Patch commited: http://source.winehq.org/git/wine.git/commitdiff/ae4571fb796dc03d91a63d6c5c2...
http://bugs.winehq.org/show_bug.cgi?id=27741
Frédéric Delanoy frederic.delanoy@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |ae4571fb796dc03d91a63d6c5c2 | |a80a08f587578 Status|NEW |RESOLVED Resolution| |FIXED
--- Comment #7 from Frédéric Delanoy frederic.delanoy@gmail.com 2012-11-06 16:20:16 CST --- Fixed by http://source.winehq.org/git/wine.git/commitdiff/ae4571fb796dc03d91a63d6c5c2...
http://bugs.winehq.org/show_bug.cgi?id=27741
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #8 from Alexandre Julliard julliard@winehq.org 2012-11-09 13:00:37 CST --- Closing bugs fixed in 1.5.17.