What is the limit on the compound statement length within ( ) of a FOR-loop?

Experiment tells me that you can have 999 &s in there. At 1000 I start to get "TCC: Command loop """. When entering very long commands I run into a hard limit at about 64K characters, nearly all of them inside DO's parentheses.
TCC doesn't have a size limit for command lines (other than what will fit in RAM). However, individual arguments are limited to 32K (filenames, the Windows limit) or 64K characters.

That said, a lot of Windows APIs will blow up if passed very long filenames, arguments or command lines.
I can't find a way to get more than 64K characters on a command line. If I have in the clipboard " xxx ... xxx" (a space followed by 4094 x's) I can paste it into a command line 16 times (a total of 64K-16 characters). After that I just get a lot of beeps. What limit is coming into play there? I don't need to do that; I just want to understand what's happening.


Staff member
May 14, 2008
The command line editing routine limits the command input to 64K characters, mostly because (1) you don't need anything bigger, and (2) it really, really slows down the editing when you get to this size, particularly when inserting characters, and (3) the cursor positioning on a command that spans many screen pages is nasty, and (4) there's a couple of Windows APIs that gork on the cursor positioning when the size gets larger than this.

But this doesn't affect how large the command line can grow to be after alias & variable expansion, or the size of the command line read from a file. (But Windows will likely explode with the really large command lines anyway.)