Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

WAD DO and escaped redirect characters

Jan
616
15
TCC 16.03.53 Windows XP [Version 5.1.2600]

From the command line, the following commands work...
Code:
echo `</test>`
echo ^</test^>
and both print out
Code:
</test>

Wrapping either in a DO...
Code:
do i = 1 to 5 ( echo `</test>` )
do i = 1 to 5 ( echo ^</test^> )
causes failure
Code:
TCC: (Sys) The system cannot find the file specified.
 ""
TCC: (Sys) The system cannot find the file specified.
 ""
TCC: (Sys) The system cannot find the file specified.
 ""
TCC: (Sys) The system cannot find the file specified.
 ""
TCC: (Sys) The system cannot find the file specified.
 ""

I've tried various other incarnations including using the %= universal escape sequence.
 
I'm not sure why, (most likely it passes through the parser twice), but if you double up the escapes it works.
Code:
do 5 (echo ^^</test^^>)
</test>
</test>
</test>
</test>
</test>
 
Or,
Code:
v:\> do i = 1 to 5 ( echo ^k</test>^k )
</test>
</test>
</test>
</test>
</test>
 
@samintz Thanks. That got me over my immediate "get my work done" hurdle.

@vefatica That works for the back quote as well (explained in the "Escape Character" portion of the help file). However, this is not explained in the DO portion of the help file. Either the parsing of DO needs to be fixed or there needs to be an addition to the DO in the help file like...
"WARNING!!!! BE SURE TO USE THE SPECIAL ESCAPE SEQUENCES IN YOUR DO COMMANDS!!!"
 
But:

Code:
for /l %i in ( 1, 1, 5 ) echo `</test>`

FOR gets parsed once, but it looks like a single-line DO is ground through the parser twice.
 
WAD. FOR is designed as a single-line loop, so it parses each element individually (for compatibility with CMD).

DO is designed as a multi-line loop, that had the ability to execute a command group on a single line grafted on to it only very recently. Changing DO to behave like FOR would (1) require a complete rewrite of DO, and (2) break all existing DO statements. Neither of those options seems particularly desirable.
 
FOR gets parsed once, but it looks like a single-line DO is ground through the parser twice.
WAD. FOR is designed as a single-line loop, so it parses each element individually (for compatibility with CMD).
I can live with that. I put the DO in a BTM as a multiline (with ENDDO) and it worked fine. I'll remember to use FOR for command line quickies. I just seem to recall reading in the past that DO should be used instead of FOR, but I've probably got my single-liners and multi-liners confused.

Thanks for everyone's help.

Edit: Possibly a documentation note about escaping in single- vs. multi- line should be added to DO?
 

Similar threads

Back
Top