Hi Tom,

Thanks for your test - it shows that Microsoft is at least consistent 
with this behaviour, as odd as it is :)

You got the same result as me on MS-DOS 6.0, ie "DOS processes the = 
character like a white space when found inside a %1, %2, %3 etc argument 
inside a batch file".

FreeDOS (FreeCOM) does that too, UNLESS the argument starts with a slash, 
in which case it preserves the entire string.

Question is... is there any way to use "%1"-like arguments in a way that 
would preserve possible '=' characters inside?

regards,
Mateusz




On Mon, 28 Nov 2016 14:53:06 +0100, Tom Ehlert wrote:
> Mateusz,
> 
> after 30 years, new insights into DOS batch processing.
> 
> on first sight, it seems to me that '=' is simply skipped by the command
> interpreter.
> testing on Windows XP (which is usually a supergroup of MSDOS)
> 
> C:>echo >test.bat echo '%1' '%2' '%3' '%4'
> 
> C:>test.bat /x=1 y=2
> 
> C:>echo '/x' '1' 'y' '2'
> '/x' '1' 'y' '2'
> 
> 
> 
> surprise, surprise
> 
> Tom
> 
> 
> 
> am 28. November 2016 um 14:10 schrieben Sie:
> 
>> Hi group,
> 
>> This message can be considered both as a minor bug report and a
>> question. Here's an introduction to what I tested:
> 
>> I wrote a trivial program that I called getargs, it simply prints out
>> the argv list:
> 
>>   #include <stdio.h>
> 
>>   int main(int argc, char **argv) {
>>     int i;
>>     printf("got %d args:\n", argc);
>>     for (i = 0; i < argc; i++) printf(" %d='%s'\n", i, argv[i]);
>>     return(0);
>>   }
> 
>> Then, I executed this program with some arbitrary parameters:
> 
>>   getargs.exe /X=5 Y=6
> 
>> on both FreeDOS and MS-DOS, it prints out things I expected, ie:
> 
>>   got 3 args:
>>    0='C:\GETARGS.EXE'
>>    1='/X=5'
>>    2='Y=6'
> 
>> and that's all fine. But now, let me introduce a twist. Instead of
>> calling getargs.exe directly, I call it through the following batch
>> file, called GETARGS.BAT:
> 
>>   @ECHO OFF C:\GETARGS.EXE %1 %2 %3 %4 %5 %6 %7 %8 %9
> 
>> and I do the same test again, but this time using getargs.bat instead
>> of getargs.exe.
> 
>> O FreeDOS, I get this:
> 
>>   got 4 args:
>>    0='C:\GETARGS.EXE'
>>    1='/X=5'
>>    2='Y'
>>    3='6'
> 
>> While MS-DOS 6 outputs this:
> 
>>   got 5 args:
>>    0='C:\GETARGS.EXE'
>>    1='/X'
>>    2='5'
>>    3='Y'
>>    4='6'
> 
>> As you can see, there is some inconsistency between how FreeDOS
>> processes this situation, and how MS-DOS treats it, this could probably
>> be considered a minor bug. But my biggest concern is about the reason
>> both decide to parse '=' as a switch delimiter in the first place, when
>> called through a batch file with %1 %2 %3 argument place-holders... Any
>> idea on that?
> 
>> Is there anything I could do to make the batch file react exactly like
>> if the exe file was launched?
> 
>> Note, that if I replace the %1 %2 variables in the batch file by actual
>> arguments (/X=4 Y=5), then the result is exactly the same as when the
>> exe file is executed directly, so I assume it's something strictly
>> related to how %1 %2 %3... variables are processed.
> 
>> I took screenshots of my tests on both FreeDOS and MS-DOS, should this
>> be useful for any purpose:
>>   https://s12.postimg.org/en1mbmgal/getargs_fdos.png
>>   https://s16.postimg.org/7uvvosqad/getargs_msdos.png
> 
>> best regards,
>> Mateusz
> 
> 
>> 
------------------------------------------------------------------------------
>> _______________________________________________
>> Freedos-devel mailing list Freedos-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/freedos-devel
> 
> 
> 
> Mit freundlichen Grüßen/Kind regards Tom Ehlert +49-241-79886
> 
> 
> 
------------------------------------------------------------------------------
> _______________________________________________
> Freedos-devel mailing list Freedos-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/freedos-devel



------------------------------------------------------------------------------
_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to