FOR %%A IN () broken
well, it is not "broken", it was simply never implemented. :)
When reading the MSDOS help I saw "runs command for each file in a set of files". I didn't knew it could be also simple strings, so SvarCOM looks only for matching files.
This is very confusing, since it means that such command:
for %d in (*.txt *.doc) do echo %d
will print existing *.txt and *.doc files, while such command:
for %d in (file.txt file.doc) do echo %d
will print "file.txt" and "file.doc", whether or not such files exist.
I assume that the differentiator here is the presence of wildcards, but that's only a guess.
Reply To mateuszviste
well, it is not "broken", it was simply never implemented. :)
Oops!
When reading the MSDOS help I saw "runs command for each file in a set of files". I didn't knew it could be also simple strings, so SvarCOM looks only for matching files.
I see.
This is very confusing, since it means that such command: for %d in (*.txt *.doc) do echo %d will print existing *.txt and *.doc files, while such command: for %d in (file.txt file.doc) do echo %d will print "file.txt" and "file.doc", whether or not such files exist. I assume that the differentiator here is the presence of wildcards, but that's only a guess.
I think, you're right. (? can also be used)
About the separators supported:
For FreeCOM it's easy, because we just have to look at the source code:
#define isargdelim(ch) (isspace(ch) || iscntrl(ch) || strchr(",;=", ch))
For MS-DOS 5.0 and 6.22 command.com I found by testing:
Other iscntrl() chars don't work. Also not working: '~?&*+-\.@!"%:<>|
So, FreeCOM behaves differently. Some would say, it has bugs.
thanks for the extensive research! rev 1055 supports the non-space delimiters and also processes expressions without wildcards (* or ?) as messages.
I built a new binary for testing.
Test batch file:
@ECHO OFF FOR %%A IN (F\OO;BAR) DO ECHO A=%%A
I would expect the following output:
A=F\OO A=BAR
But I get:
A=FF\OO A=BAR
There is an issue with the backslash. This also still prevents WHICH.BAT to work.
Additionally I found, redirecting the batch file's output to a log file doesn't work. It just doesn't create a new file.
Reply To bttr
Additionally I found, redirecting the batch file's output to a log file doesn't work. It just doesn't create a new file.
This is on purpose, it is not supposed to work.
Reply To mateuszviste
Reply To bttr
Additionally I found, redirecting the batch file's output to a log file doesn't work. It just doesn't create a new file.
This is on purpose, it is not supposed to work.
If you aim for SvarCOM being a drop-in replacement for MS command.com or FreeCOM, this needs to change.
Reply To bttr
Reply To mateuszviste
Reply To bttr
Additionally I found, redirecting the batch file's output to a log file doesn't work. It just doesn't create a new file.
This is on purpose, it is not supposed to work.
If you aim for SvarCOM being a drop-in replacement for MS command.com or FreeCOM, this needs to change.
Can you tell which MS-DOS version allows to redirect the output of a bat file?
Reply To bttr
Test batch file: {{{ @ECHO OFF FOR %%A IN (F\OO;BAR) DO ECHO A=%%A }}} I would expect the following output: {{{ A=F\OO A=BAR }}} But I get: {{{ A=FF\OO A=BAR }}}
Fixed in rev 1070.
For the record, this is from the PTS-DOS manual:
3.1.5 FOR Command Purpose: Performs the FOR cycle. Syntax: FOR %var IN (LIST) DO COMMAND or FOR [/?][/H[ELP]] Parameters: Var - one-letter variable (a-z or A-Z), LIST - list of arguments with standard separators, COMMAND - DOS command. It can contain the string "%var", that will be substituted for a value from the LIST. /? or /H or /HELP - help. Note: The LIST elements are considered to be files or directories first, and then a text.
They just call it 'list' and 'list elements'. :-D
Fix confirmed for SvarCOM version 2022.3.
Reply To mateuszviste
Reply To bttr
Reply To mateuszviste
Reply To bttr
Additionally I found, redirecting the batch file's output to a log file doesn't work. It just doesn't create a new file.
This is on purpose, it is not supposed to work.
If you aim for SvarCOM being a drop-in replacement for MS command.com or FreeCOM, this needs to change.
Can you tell which MS-DOS version allows to redirect the output of a bat file?
Sorry, my fault. I was under the impression, that this would work in MS-DOS (6.22).
(Split from https://osdn.net/projects/svardos/ticket/44051#comment:12510:44051:1646752457 and https://osdn.net/projects/svardos/ticket/44051#comment:12510:44051:1646756790)
This would print:
with FreeCOM and MS command.com.With the recent SvarCOM there is no output produced at all.
Same result, after replacing ECHO with TYPE.