Switch Case and here-document redirection

May 30, 2008
235
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
11,400
99
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
235
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
Thread starter Title Forum Replies Date
F WAD SWITCH statement with regexes or wildcards as CASE expressions Support 9
A I'd like a clarification on the/N switch Support 11
Emilio III pdir /f switch Support 1
A Fixed (CMD compat) START /D fails to recognize the switch option. Support 3
A TCC /S switch observations Support 2
rps Documentation "Select" command switch order incorrect Support 4
fpefpe How to? start command /tab option/switch Support 6
Joe Caverly Sort-of Missing Switch for START in Help Support 7
T TCMD tab switch keys Support 20
T DEL disregards switch when using regular expressions Support 2
Stefano Piccardi TCMD 9.02.152 locale switch keys Support 0
Stefano Piccardi DO ignores switch /D ? Support 1
nikbackm Alias expansion and switch character Support 2
M How to? Set the ribbon titles to mixed case Support 1
vefatica WAD Escaping changes case to lower? Support 12
Frank @replace works case sensitive Support 5
M WAD A case where the "List" command is clearly not working at all... Support 4
S Dir - case selection possible?? Support 3
S FFIND /E"reg exp" : not case insensitive Support 4
Joe Caverly Here-Document on new Install Support 21
T @replace -- what is wrong here Support 2
J Vers. 18 Here doc redirection broken? Support 4
B Newbie here, I have a question. Support 4
M What's going on here????? Support 6
A Here document Support 3
M Simply put, Help! (I can't figure out what's going on here.) Support 6
M What am I doing wrong here? Support 2
Mordachai TCMD Prompt Here?!@ Support 14
K_Meinhard Fixed ? TCMD 14.02 doesn't start here Support 4
vefatica What's wrong here? Support 2
vefatica What's happening here? Support 3
Charles Dye Strange output, here-doc redirection, TYPE, //UnicodeOutput=Yes Support 6
CWBillow TCMD prompt here only opens to root Support 6
M open Take Command here right-click? Support 2
H "Here-String" redirection not working Support 6
M TCC Prompt Here Colors Support 0
E Single instance/TCMD Here problem Support 7
R Start Prompt Here? Support 9
vefatica What's happening here? Support 9

Similar threads