Page 1 of 1

strange FOR behavior

Posted: 23 Jun 2021 05:09
by findstr
Hello!
In interactive cmd.exe prompt:

Code: Select all

cmd /V:ON
set counter=0 & for /L %K in (1,1,6) do @(set /a counter+=1 & echo !counter!)
The result is:

Code: Select all

11
22
33
44
55
66
I expected it to be:

Code: Select all

1
2
3
4
5
6
What's wrong here?
Thanks!

Re: strange FOR behavior

Posted: 23 Jun 2021 05:54
by aGerman
It's not a matter of FOR. It's SET /A which already prints the result if executed in a command line.

Code: Select all

@set /a x+=1
Steffen