tcmd crashes in this recursive "for /f" loop

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Apr 7, 2010
The attached batch file is just a simple test to echo each directory in PATH on a separate line. Works fine in cmd.exe. tcmd totally crashes. Is it due to the recursion? Or maybe the "for /f" in cmd.exe and tcmd.exe are different? What am I doing wrong?

using version: 15.00.25 x64



Staff member
May 14, 2008
That's an ... inefficient way to parse the PATH! It's eating more than 20Mb of stack space, which results in the RTL crashing. TCC will use a lot more stack per recursion level than CMD because (1) TCC supports much larger lines, and (2) TCC has at least 100x more features than CMD.

Is your intention to have a single batch file run in both TCC and CMD? (If you only care about running it in TCC, you can get rid of 90% of your code.)
Apr 7, 2010
Thanks for the reply. Actually, I was just outlining a possible approach for something a bit more complicated and just using path parsing as a starting point. I ended up doing all the work in a perl script embedded in the batch file and then passing the result back to the batch script.

I was just startled by the flat out crash, but figured it was due to the recursion. Thank you for the quick reply.