It's worse (much worse) than you think. I used to think that CMD's FOR had the most appalling syntax, but SET has it beat by a mile.
The internal commands in CMD all have their own parser, which makes for at best an uneven and unexpected experience. One of the goals of 4DOS / 4NT / TCC was to use a unified parser with consistent syntax (albeit with a handful of ugly kludges thrown in to match CMD bugs that have inexplicably become "features").
But SET has at least *two* parsers (incompatible with each other), and I strongly suspect given some odd behavior I haven't been able to fully define yet that there is at least one more. Depending on how & where you use SET, and what arguments you provide, SET will either:
- Preserve all trailing whitespace
- Trim all trailing whitespace
- Add one trailing space
- Add two trailing spaces
- Truncate non-whitespace characters
And let's not even get started on the times that SET deletes whitespace in the middle of the argument.
I've tried to preserve as much compatibility with CMD behavior as possible without screwing up TCC features, but the erratic trailing whitespace behavior in CMD is pushing it too far. I've decided for build 21.01.58 and later to drop trying (when in TCC mode) to support it unless you use the (somewhat documented) quote behavior:
set "var=abc "
If you set CMD compatibility mode you'll still get all of the awful, unexpected and thoroughly misconceived CMD behavior.