Re: [Freedos-devel] odd FreeDOS batch %1 %2 %3 behavior (differs from MS-DOS, too)

2016-12-03 Thread Joe Forster/STA

Hi guys,


I don't have any solution to the problem but while on the topic of FreeCOM
and batch file parameters, I have discovered an issue which I believe is a
genuine bug.

Create a batch file, for example:

ECHO %1 %2 %3 %4 %5 %6 %7 %8 %9

Then run it with a parameter like "http://www.example.com/";. It will print

http: //www.example.com /

while MS-DOS and Windows will print it unmodified.


I can confirm this but I think it's _not_a_bug_, rather intentionally 
different behavior. (I know, this also means compatibility problems.) 
Apparently, COMMAND.COM cuts apart switches in the command line into 
stand-alone arguments. Your example is considered as:

1. a command "http:";
2. a switch "//www.example.com", with double switch characters;
3. a switch "/", an empty switch.

You can prove this by adding "switchar=$" (only one "c"!) to 
[fd]config.sys which changes the system-wide switch character to "$". Now 
your example will be printed as "http://www.example.com/"; but 
"http:$$www.example.com$" will be similary cut into pieces as "http: 
$$www.example.com $".


Always enclose "suspicious" command line arguments into quotation marks 
so that they won't be reinterpreted in unexpected ways and that's not 
even DOS- or COMMAND.COM-specific.


Joe
--
KOVÁCS Balázs aka Joe Forster/STA; s...@c64.rulez.org; http://sta.c64.org
Don't E-mail spam, HTML or uncompressed files! More contacts on homepage--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] odd FreeDOS batch %1 %2 %3 behavior (differs from MS-DOS, too)

2016-12-03 Thread Matej Horvat
I don't have any solution to the problem but while on the topic of FreeCOM  
and batch file parameters, I have discovered an issue which I believe is a  
genuine bug.

Create a batch file, for example:

ECHO %1 %2 %3 %4 %5 %6 %7 %8 %9

Then run it with a parameter like "http://www.example.com/";. It will print

http: //www.example.com /

while MS-DOS and Windows will print it unmodified.

--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] odd FreeDOS batch %1 %2 %3 behavior (differs from MS-DOS, too)

2016-11-29 Thread Eric Auer
To add my 2 cents regarding link files...

For stuff like DJGPP which has many tools, it is probably
a good idea to make a SEPARATE directory for installing DJGPP
and add that to the PATH :-) As NASM only includes a few files,
it can indeed be in the generic FreeDOS bin directory anyway.

Cheers, Eric



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


Re: [Freedos-devel] odd FreeDOS batch %1 %2 %3 behavior (differs from MS-DOS, too)

2016-11-29 Thread Tom Ehlert
> Thank you for sharing your insight. It clearly looks like I will have to
> figure out an alternative approach to my batch files.

> Context: Such batch files are created by FDNPKG, my FreeDOS package 
> manager, as "links" to some commonly used applications like zip, upx, 
> nasm, etc, to avoid having to put them all in a single directory within
> the %PATH% (and to avoid exploding the environment with a huge %PATH% 
> containing dozens of directories). FDNPKG creates "link" files that are
> all stored in a dedicated directory on the disk, where each link file 
> calls its parent application directly in the directory where said parent
> application is installed, passing the same arguments through %1 %2 %3...

unfortunately DOS does not work this way.

this requires the calling program (MAKE, VC, or similar) do be smart
and differentiate between .EXE/.COM files which can be executed
directly using spawnXY("GETARGS.EXE"), and .BAT files that require an
additional COMMAND.COM instance, eating precious memory.
not good.


> This worked beautifully for me for years, until recently when I tried to
> compile things passing parameters like -DXX=YY to nasm.

xyZIP programs also have extension lists where extensions are
separated by ','

> Anyway, I will most probably have to work on some kind of small *.COM 
> loader that would replace what I do with batches now... To be continued
> somewhere in the future.

what exactly is the advantage of placing NASM.EXE files in

   c:\utils\nasm\nasm.exe

with a link file in C:\BIN, instead of copying nasm.exe in the BIN
directory as has been praxis for 30 years?

Tom


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


Re: [Freedos-devel] odd FreeDOS batch %1 %2 %3 behavior (differs from MS-DOS, too)

2016-11-29 Thread Mateusz Viste
Hi Bret,

Thank you for sharing your insight. It clearly looks like I will have to 
figure out an alternative approach to my batch files.

Context: Such batch files are created by FDNPKG, my FreeDOS package 
manager, as "links" to some commonly used applications like zip, upx, 
nasm, etc, to avoid having to put them all in a single directory within 
the %PATH% (and to avoid exploding the environment with a huge %PATH% 
containing dozens of directories). FDNPKG creates "link" files that are 
all stored in a dedicated directory on the disk, where each link file 
calls its parent application directly in the directory where said parent 
application is installed, passing the same arguments through %1 %2 %3...

This worked beautifully for me for years, until recently when I tried to 
compile things passing parameters like -DXX=YY to nasm.

Anyway, I will most probably have to work on some kind of small *.COM 
loader that would replace what I do with batches now... To be continued 
somewhere in the future.

Mateusz




On Tue, 29 Nov 2016 00:49:39 +, Bret Johnson wrote:
> The equals sign is "special" when the DOS shell is processing values
> from the command line, and different versions of DOS may treat it
> differently.  For example, in the FOR command it is basically treated as
> white space (the same as commas and real spaces).  At least in some
> versions of DOS, the following are equivalent:
> 
> FOR %f in (1 2 3) DO DIR %f.EXE FOR %f in (1,2,3) DO DIR %f.EXE FOR %f
> in (1=2=3) DO DIR %f.EXE
> 
> Also, you can't normally have an equals sign in any part of an
> environment variable (either its name or its contents), though you can
> sometimes manipulate things with double quotes to make it happen (with
> some versions of DOS, at least).
> 
> You can also use an equals sign after ECHO with some versions of DOS to
> write an empty line:
> 
> ECHO=
> 
> 
> In your batch examples, the equals sign is not being treated as a switch
> character, it is be treated (sometimes) as white space.  There's no way
> your batch files will work consistently across different DOSes if you
> expect them to treat equals signs as "regular" characters.


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


Re: [Freedos-devel] odd FreeDOS batch %1 %2 %3 behavior (differs from MS-DOS, too)

2016-11-29 Thread Mateusz Viste
On Mon, 28 Nov 2016 17:58:14 -0600, Rugxulo wrote:
> Maybe put double quotes " " around args when invoking the .BAT?

This doesn't change anything regarding how the equal characters are 
processed. Worse even, the callee ends up being called with too many 
arguments each time, since each "" argument is considered as a valid 
(empty) parameter. Observed with FreeCOM at least.

=== getargs.bat ===
@ECHO OFF
GETARGS.EXE "%1" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9"

=== executing test... ===
GETARGS.BAT /X=4 Y=5
got 10 args:
 0='C:\GETARGS.EXE'
 1='/X=4'
 2='Y'
 3='5'
 4=''
 5=''
 6=''
 7=''
 8=''
 9=''

Mateusz


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


Re: [Freedos-devel] odd FreeDOS batch %1 %2 %3 behavior (differs from MS-DOS, too)

2016-11-28 Thread Bret Johnson
The equals sign is "special" when the DOS shell is processing values from the 
command line, and different versions of DOS may treat it differently.  For 
example, in the FOR command it is basically treated as white space (the same as 
commas and real spaces).  At least in some versions of DOS, the following are 
equivalent:

FOR %f in (1 2 3) DO DIR %f.EXE
FOR %f in (1,2,3) DO DIR %f.EXE
FOR %f in (1=2=3) DO DIR %f.EXE

Also, you can't normally have an equals sign in any part of an environment 
variable (either its name or its contents), though you can sometimes manipulate 
things with double quotes to make it happen (with some versions of DOS, at 
least).

You can also use an equals sign after ECHO with some versions of DOS to write 
an empty line:

ECHO=


In your batch examples, the equals sign is not being treated as a switch 
character, it is be treated (sometimes) as white space.  There's no way your 
batch files will work consistently across different DOSes if you expect them to 
treat equals signs as "regular" characters.

How To Remove Eye Bags & Lip Lines Fast (Watch)
Womans Weekly
http://thirdpartyoffers.juno.com/TGL3141/583cd0e62025b50e56f73st01vuc

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


Re: [Freedos-devel] odd FreeDOS batch %1 %2 %3 behavior (differs from MS-DOS, too)

2016-11-28 Thread Rugxulo
Hi,

On Mon, Nov 28, 2016 at 9:15 AM, Mateusz Viste  wrote:
>
> Question is... is there any way to use "%1"-like arguments in a way that
> would preserve possible '=' characters inside?

Maybe put double quotes " " around args when invoking the .BAT? (Or
use a superior shell like 4DOS.)

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


Re: [Freedos-devel] odd FreeDOS batch %1 %2 %3 behavior (differs from MS-DOS, too)

2016-11-28 Thread Mateusz Viste
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 
> 
>>   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


Re: [Freedos-devel] odd FreeDOS batch %1 %2 %3 behavior (differs from MS-DOS, too)

2016-11-28 Thread Tom Ehlert
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 

>   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] odd FreeDOS batch %1 %2 %3 behavior (differs from MS-DOS, too)

2016-11-28 Thread Mateusz Viste
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 

  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.

On 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