During my frustrating journey to "tag" all my builds with:-
the name of who built it
the machine it was built on
the file that was compiled
the date and time
and my annoyance that arduino does not provide native access to environment variables (does not expand %USERNAME%), and that the "echo" command does not have any way to output newlines - I stumbled across a windows (cmd.exe) weirdness:
In .bat files, the caret ^ is used to escape some things - so of course, I wrote a script to see what it does in front of all 256 ASCII characters.
^(ctrl-Z) behaves really curiously. It stops and says "More?" then repeats back whatever got typed in next.
any idea what that's all about? Is this some kind of sneaky backdoor maybe?
Ctrl-Z is the End of File (EOF) character. It is a control character used to mark the end of a file in some contexts, particularly in text files. When you type Ctrl-Z in the Command Prompt, it doesn't interpret it as a control character (the caret ^ character is normally used as an escape character to treat the following character as a literal character). Instead, it pauses the batch file and asks, "More?" This is a way to signal the end of input or content without actually ending the batch script. It's used in the context of input redirection.
For example, if you are reading input from a file using a batch script and you want to mark the end of the file, you can use Ctrl-Z, and the Command Prompt will understand this as a signal to stop processing the input from that file and wait for more input or commands.
So It's not a backdoor, just a legacy feature that dates back to the early days of command-line interfaces and is still present in Windows Command Prompt likely for compatibility reasons.
Not exactly the same thing - watching stuff do its job isn't the same as writing the stuff doing that job - either way - yeah, you see a lot of info, but none of it includes the sketchbook path in any way that's usable.
Hint - I said {built.in.paths} for a reason. Same goes for %ENV% variables too - incredibly frustrating how the original authors decided to block those, and not to give us the most basic of necessary paths to work our scripts from.
when you do put it in a batch file, it doesn't pause it (see screenshot - it does entirely inexplicable things instead - hence my question)
I do understand the significance of the old ^Z EOF, and interestingly, ^^Z does not stop the batch file there either.
If you were a programmer trying to hide something sketchy inside the batch-script processor - that's pretty much the most likely idea to use (not to mention - continuing to process a file after the EOF marker is reached is already sketchy to start with...)
(I'm an old-school DoS hacker (since 1985), and never seen that one before)
They didn't decide to "block" them. Rather the commands are not invoked using the Windows command interpreter. As your project shows, if you do use cmd /C to use Windows command interpreter to invoke the commands then you can access such variables.
After a decade of working with and supporting those using the Arduino platform system, this is the first time I have seen anyone interested in having a sketchbook path property. The sketch path is useful, and available in multiple forms (both the path to the working copy and the saved sketch), but claiming the sketchbook path is "the most basic of necessary paths" is quite a stretch!
You found an obscure use for it in your project, but even with a sketchbook path property, your use case is a bit hacky due to the need to assume the library folder name.
I just noticed to did not run the batch file but actually just used "type" to see its content
may be an explanation is there
type would then assume that the ctrl-Z it got would be the end of the file, but it sees from the metadata there are more bytes after that, so asks if you want to see "More" ?