1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

tcmd crashes in this recursive "for /f" loop

Discussion in 'Support' started by Mel Davis, Apr 19, 2013.

  1. Mel Davis

    Joined:
    Apr 7, 2010
    Messages:
    19
    Likes Received:
    0
    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
     

    Attached Files:

  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,804
    Likes Received:
    82
    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.)
     
  3. Mel Davis

    Joined:
    Apr 7, 2010
    Messages:
    19
    Likes Received:
    0
    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.
     
  4. Frank

    Joined:
    Aug 2, 2011
    Messages:
    258
    Likes Received:
    4
  5. Mel Davis

    Joined:
    Apr 7, 2010
    Messages:
    19
    Likes Received:
    0
    Wow! Thanks, it's perfect.
     

Share This Page