Switch Case and here-document redirection

May 30, 2008
238
2
I have some batch files using here-document redirection in switch case commands.

This used to work in v15 but fails in v20. I got v20 to work by extracting the case commands to a separate sub-routine.

Is this something that should be fixed in TCC or a (new) limitation of the switch statement?

Code:
@echo off

switch s
case s
   wc.exe << endinput
   1
   2
   3
   endinput
endswitch

This works in v15 but fails in v20.

Code:
@echo off

switch s
case s
   gosub runwc
endswitch
quit

:runwc
wc.exe << endinput
1
2
3
endinput
return

This works in both v15 and v20.
 
May 20, 2008
12,167
133
Syracuse, NY, USA
It will work better if you either

1. remove the whitespace before "endinput", or
2. use "<<-" instead of "<<"

But you are right. There was a change in behavior (between v16 and v17).
 
May 30, 2008
238
2
Thank you!

That did indeed fix the problems I had. Seems the whitespace before the end-marker confused the parser in the later versions.
 

Similar threads