Re: [Freedos-devel] EXIST NUL

2023-06-14 Thread Steve Nickolas

On Wed, 14 Jun 2023, Mercury Thirteen via Freedos-devel wrote:


Unfortunately, in many cases, it has to be an absolute rule.

I totally get the mindset (and semi-subscribe to it myself)of wanting 
FreeDOS to be a kind of MS-DOS but improved in every way possible 
including fixing Microsoft's bugs, but realistically that cannot be in 
all cases since some legacy software out there may very well be relying 
on a specific behavior present in MS-DOS and us fixing that bug - even 
when normally be the right thing to do - may break compatibility in 
those cases.


This... MS-DOS and PC DOS have been "the norm" for so long that a lot of 
software relies on bugs and corner cases, and falls apart if they aren't 
supported.


-uso.


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


Re: [Freedos-devel] EXIST NUL

2023-06-14 Thread Mercury Thirteen via Freedos-devel
On Tuesday, June 13th, 2023 at 4:30 PM, Jose Senna jasse...@mail.com wrote:

> ...
>
> Jim Hall said:
>
>> We should still fix the FreeDOS behavior to match
>
>> the MS-DOS behavior.
>
> Shall this be an absolute rule, even when the
> behavior is a bug ?

Unfortunately, in many cases, it has to be an absolute rule.

I totally get the mindset (and semi-subscribe to it myself)of wanting FreeDOS 
to be a kind of MS-DOS but improved in every way possible including fixing 
Microsoft's bugs, but realistically that cannot be in all cases since some 
legacy software out there may very well be relying on a specific behavior 
present in MS-DOS and us fixing that bug - even when normally be the right 
thing to do - may break compatibility in those cases.

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


Re: [Freedos-devel] EXIST NUL

2023-06-13 Thread jerome


> On Jun 13, 2023, at 4:02 PM, Jim Hall  wrote:
> 
> On Mon, Jun 12, 2023 at 4:05 PM Bret Johnson  wrote:
>> 
>> Rather than merely trying to copy the way MS did/does things regarding
>> IF EXIST X:NUL, I think we can discuss what the "right" way to handle
>> things should be.
> 
> We should still fix the FreeDOS behavior to match the MS-DOS behavior.

Issue #2 is simply a bug.

Issue #1 is a little different. Although Issue #1 matches the behavior of 
MS-DOS, it 
can be assumed to be a bug as well. Even Microsoft changed this to be 
consistent 
in Windows Command Shell at some point. 

> But if we're going to talk about the "right" way to do things, what
> about a new, separate "test" command to evaluate things?
> 
> I'm using Unix and Linux as a model, but not suggesting we emulate
> completely the features of Unix. But the Unix 'test' tool does some
> neat things. My suggestions for a "test" like command:
> 
> TEST /F file
> Returns errorlevel zero if the file exists, nonzero if not. This is like 
> doing:
> IF EXIST d:\path\file [..]
> ..but it puts the test on a separate line in the batch file, and you
> use the errorlevel afterwards to do your condition.
> 
> TEST /D dir
> Returns errorlevel zero if the dir exists, nonzero if not. This is like doing:
> IF EXIST d:\path\NUL [..]
> ..but it can be made more reliable.
> 
> 
> I think string tests are also useful:
> 
> 
> TEST /Z str
> Returns zero if the str is empty, nonzero if not. This is like doing:
> IF z%VAR%==z [..]
> ..but it makes the test more obvious.
> 
> TEST /S str
> Returns zero if the str is not empty, nonzero if empty. This is the
> opposite of "TEST /z str"
> 
> 
> Number value comparisons can also be a handy thing for some batch files:
> 
> 
> TEST /n n1 comp n2
> Test various comparisons on numbers. My nature is to use Fortran-like
> comparisons here, like:
> 
> TEST /n a LT b
> TEST /n a LE b
> Returns errorlevel zero if "a" is less than "b" (for LE, "less than or
> equal") nonzero if not
> 
> TEST /n a GT b
> TEST /n a GE b
> Returns errorlevel zero if "a" is greater than "b" (for GE, "greater
> than or equal") nonzero if not
> 
> TEST /n a EQ b
> Returns errorlevel zero if "a" is equal to "b", nonzero if not
> 
> TEST /n a NE b
> Returns errorlevel zero if "a" is not equal to "b", nonzero if not

I was going to wait until it was completely finished. But, there is no
harm in announcing it now.

I have already written a utility that does this and much more. It is part of 
V8Power Tools for DOS and called VTEST. It weighs in at under 3Kb. 
Because like all the programs in V8PT, it is written in assembly. 

It is capable of things like:

vtest 1234567890123 /gt -56789012345 
vtest /not hello /eq goodbye /and /d c:\ /and /not /f readme.txt
vtest 1 /lt 2 /lt 5 /gt 3 /and /not /c hello my friend /gt Goodbye /or /v 15
vtest  /f 00*.* /lt 005.txt 
vtest /not /f This text document.doc /and /not /f That text document.doc

It 64-bit numbers, long file names and even both case-specific and case-less 
string comparisons. 

All that is working great and it will be available for general testing sometime 
over the next few days. If I can spare a few minutes, possibly tomorrow.

If you are interested, the help text for VTEST can be viewed at:

https://github.com/shidel/fd-nls/blob/master/v8power/help/en/vtest.en 


Source is at:

https://github.com/LoopZ/V8Power/blob/master/SOURCE/VTEST.ASM 


Binary will be available soon.


Jerome

> 
> 
> ___
> 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] EXIST NUL

2023-06-13 Thread Jose Senna
 Bret Johnson said:

 > The second questions is, "Does a device exist in
 > all existing directories, or only certain ones?"
 > The answer to that question is that it is supposed
 > to "exist" in ALL directories.

   I fully agree with the answer.
   I did not think this was a question, because the
  answer was so obvious,

 Jim Hall said:

 > We should still fix the FreeDOS behavior to match
 > the MS-DOS behavior.

   Shall this be an absolute rule, even when the
  behavior is a bug ?



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


Re: [Freedos-devel] EXIST NUL

2023-06-13 Thread Jim Hall
On Mon, Jun 12, 2023 at 4:05 PM Bret Johnson  wrote:
>
> Rather than merely trying to copy the way MS did/does things regarding
> IF EXIST X:NUL, I think we can discuss what the "right" way to handle
> things should be.

We should still fix the FreeDOS behavior to match the MS-DOS behavior.
But if we're going to talk about the "right" way to do things, what
about a new, separate "test" command to evaluate things?

I'm using Unix and Linux as a model, but not suggesting we emulate
completely the features of Unix. But the Unix 'test' tool does some
neat things. My suggestions for a "test" like command:

TEST /F file
Returns errorlevel zero if the file exists, nonzero if not. This is like doing:
IF EXIST d:\path\file [..]
..but it puts the test on a separate line in the batch file, and you
use the errorlevel afterwards to do your condition.

TEST /D dir
Returns errorlevel zero if the dir exists, nonzero if not. This is like doing:
IF EXIST d:\path\NUL [..]
..but it can be made more reliable.


I think string tests are also useful:


TEST /Z str
Returns zero if the str is empty, nonzero if not. This is like doing:
IF z%VAR%==z [..]
..but it makes the test more obvious.

TEST /S str
Returns zero if the str is not empty, nonzero if empty. This is the
opposite of "TEST /z str"


Number value comparisons can also be a handy thing for some batch files:


TEST /n n1 comp n2
Test various comparisons on numbers. My nature is to use Fortran-like
comparisons here, like:

TEST /n a LT b
TEST /n a LE b
Returns errorlevel zero if "a" is less than "b" (for LE, "less than or
equal") nonzero if not

TEST /n a GT b
TEST /n a GE b
Returns errorlevel zero if "a" is greater than "b" (for GE, "greater
than or equal") nonzero if not

TEST /n a EQ b
Returns errorlevel zero if "a" is equal to "b", nonzero if not

TEST /n a NE b
Returns errorlevel zero if "a" is not equal to "b", nonzero if not


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


Re: [Freedos-devel] EXIST NUL

2023-06-13 Thread Bret Johnson
> It seems to me that te question is "Shall a device
> exist in a non-existing directory ?"

I don't think that's the correct question.  I think there are two questions.  
The first question is, "Does a device exist in a non-existent directory?"  The 
answer to that is no -- a device does not exist in an "imaginary" place that 
you cannot actually navigate to.  In that sense, it has the same 
characteristics as a "normal" file.

The second questions is, "Does a device exist in all existing directories, or 
only certain ones?"  The answer to that question is that it is supposed to 
"exist" in ALL directories.  If you can navigate to a directory, ALL devices 
"exist" there (at least for the purposes of an "IF EXIST" test).  For example, 
if you navigate to an existing directory on a floppy drive that's already full 
and has no room left for any "real" files, or a read-only device like a CD-ROM, 
the NUL device (and all other character devices) still "exist" there.  In 
addition, you can write to a character device (like NUL) even if the directory 
itself is read-only.  In that sense, it is different than a "normal" file.

That's why you can use the IF EXIST test (with a character device name in place 
of the file name) to test for the existence of a directory instead of a file, 
and it should work for any directory that is navigable.


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


[Freedos-devel] EXIST NUL

2023-06-13 Thread Jose Senna
Bret Johnson said:

> Rather than merely trying to copy the way MS did/does
> things regarding IF EXIST X:NUL, I think we can discuss
> what the "right" way to handle things should be.

 It seems to me that te question is "Shall a device
 exist in a non-existing directory ?"




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


Re: [Freedos-devel] EXIST NUL

2023-06-12 Thread Bret Johnson
Rather than merely trying to copy the way MS did/does things regarding IF EXIST 
X:NUL, I think we can discuss what the "right" way to handle things should be.

NUL is a device, not a file, though it can sort of look like it is a file in 
some circumstances.  In at least a sense, any device (NUL or CON or whatever) 
is a "file" (or at least a file name) that exists everywhere -- on every disk 
and directory there is, be it networked or removable or whatever (BTW, this is 
different than how *nix handles things).  This concept is much more obvious 
when you don't try and put a disk and/or directory name in front of the NUL -- 
no matter where you are, you can tell DOS to send something the NUL (or any 
other) device and DOS knows "where" it is.  You can either think of it as being 
"an extension of the DOS kernel" or being "inside every drive and directory 
that DOS can see."  Of course, neither analogy is quite correct, but you can 
sort of think of it in those terms.

To DOS, the device variously called NUL, NUL: (with a colon), and C:\NUL always 
exist (if C:\ exists, so does C:\NUL).  If you want to refer to a _file_ called 
C:\NUL instead of the NUL device, you need to put a period at the end (C:\NUL.) 
to explicitly tell DOS you're talking about a file (with no extension) instead 
of a device.  You can also put a colon at the end (C:\NUL:) to explicitly tell 
DOS you are referring to the device called NUL (even if the C:\NUL. file 
exists).  

That's my understanding of how it is _supposed_ to work, anyway, even if it 
doesn't always do that.


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


Re: [Freedos-devel] EXIST NUL

2023-06-06 Thread jerome
Hi Ralf,

To further prove Issue #1 is a bug under both the current version of FreeDOS 
and last version of MS-DOS (6.22),

I booted up a Windows 10 machine and opened a command shell window. 

On that machine, drive Z: is a CDROM (with disk inserted) and drive T: does not 
exist. 

C:>if exist C:\NUL echo yes
yes
C:>if exist T:\NUL echo yes
C:>if exist Z:\NUL echo yes
yes
C:>

Although the Windows 10 command shell is not DOS, Microsoft did correct this 
behavior at a later point for batch processing.

:-)

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


Re: [Freedos-devel] EXIST NUL

2023-06-06 Thread tom ehlert
Hallo Herr Ralf Quint,

am Montag, 5. Juni 2023 um 23:06 schrieben Sie:

> On 6/5/2023 1:56 AM, jer...@shidel.net wrote:
>>
>> Hi All,
>>
>> /There are two separate issues when using: |IF EXIST ?:\NUL| /
>>
>> /I'm lazy and wrote up a info text file over at > 
>> https://fd.lod.bz/redist/testing/devNUL/ and /
>>
>> /bug //report at //https://github.com/FDOS/freecom //that I will just > 
>> copy/paste here. /
>>
>> /Additional testing would be required to determine the cause of these > 
>> problems. Since /
>>
>> /the same problem exists for Issue #1 under MS-DOS, an argument could > be 
>> made to /
>>
>> /not fix that problem./
>>
> I am not sure why you would think this is a bug at all. 

because it differs from MSDOS.

> I am pretty sure that this test will not only fail for CD-ROM drives, but for 
> mapped network drives as well, as MSCDEX is nothing but a version of the 
> network redirector.

if exist D:\NUL

works for fixed and RAM disks in MSDOS.

this even worked in FreeDOS until it was broken in ~2003 n by PerditionC by 
some change in truename().

Tom



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


Re: [Freedos-devel] EXIST NUL

2023-06-05 Thread jerome
Hi Ralf, 

> On Jun 5, 2023, at 5:06 PM, Ralf Quint  wrote:
> 
> On 6/5/2023 1:56 AM, jer...@shidel.net  wrote:
>> Hi All,
>> 
>> There are two separate issues when using:  IF EXIST ?:\NUL 
>> 
>> I'm lazy and wrote up a info text file over at 
>> https://fd.lod.bz/redist/testing/devNUL/ 
>>  and 
>> 
>> bug report at https://github.com/FDOS/freecom 
>>  that I will just copy/paste here. 
>> 
>> Additional testing would be required to determine the cause of these 
>> problems. Since 
>> the same problem exists for Issue #1 under MS-DOS, an argument could be made 
>> to 
>> 
>> not fix that problem.
> I am not sure why you would think this is a bug at all. I am pretty sure that 
> this test will not only fail for CD-ROM drives, but for mapped network drives 
> as well, as MSCDEX is nothing but a version of the network redirector.
> 
For Issue #1… 

I did write “The result is always FALSE”  for CD or Network Drives. 

Yep, it is most likely involves the redirector. 

I feel it is a bug because the behavior deviates from that of other system 
drives.  

For example, assume that an internal drive D: exists and NETWORK drive N: 
exists and is mounted. 

IF EXIST D:\NUL echo Drive D: exists.
IF EXIST N:\NUL echo Drive N: exists.

When executing such commands in a batch file, only "Drive D: exists.” would be 
displayed.

This makes testing for NUL useless in determining wether or not a 
drive/directory exists. Not does it behave as one would expect.

Lets say your AUTOEXEC has some instructions to conditionally add directories 
to the PATH. Maybe something like this:

IF EXIST D:\TOOLS\NUL SET PATH=D:\TOOLS;%PATH%
IF EXIST N:\TOOLS\NUL SET PATH=N:\TOOLS;%PATH%

The N:\TOOLS directory would never be inserted into the PATH.

Under the current behavior, testing NUL should never be used to SIMPLY test if 
a drive or directory exists. 

However…

At present, it could be used to detect if a drive might possibly disappear 
while the system is running. 

Although floppy drives behave like internal hard drives, one can assume 
anything on either drive A: or B: might be removed. 

A batch program could conditionally adds a directory to PATH when the drive 
will never disappear from the running system.

REM %DRV% is the drive to test before inserting the directory in PATH
REM Only local drives with fixed media will be inserted into the path
IF “%DRV%” == “A:” GOTO NO_ADD
IF “%DRV%” == “B:” GOTO NO_ADD
IF NOT EXIST %DRV%\TOOLS\NUL GOTO NO_ADD
SET PATH=%DRV%\TOOLS;%PATH%
:NO_ADD

So, it is possibly that there are batch programs that do rely on this behavior. 

Also, it is probably more often the case that a batch would need to know if a 
file exists in a directory and not that a directory simply exists. 
Testing if a file exists on a CD or Network share does work as expected. 

IF EXIST N:\TOOLS\MYTOOL.EXE SET PATH=N:\TOOLS;%PATH%

That would add the N:\TOOLS path if MYTOOL.EXE is present in that directory. 

:-)

Jerome


> Ralf
> ___
> 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


[Freedos-devel] EXIST NUL

2023-06-05 Thread jerome
Hi All,

There are two separate issues when using:  IF EXIST ?:\NUL 

I'm lazy and wrote up a info text file over at 
https://fd.lod.bz/redist/testing/devNUL/ 
 and 

bug report at https://github.com/FDOS/freecom  
that I will just copy/paste here. 

Additional testing would be required to determine the cause of these problems. 
Since 
the same problem exists for Issue #1 under MS-DOS, an argument could be made to 

not fix that problem. As for Issue #2, it is a FreeDOS specific bug and will 
need fixed. 

:-)

Jerome

NUL Device Existence Test

https://fd.lod.bz/redist/testing/devNUL/ 

2023-05-23

This test reveals two separate issues:

Issue 1:

Testing for the existence of a path by using the NUL device does not
work on CD/DVD drives or Network Shares. The result is always FALSE.

IF EXIST N:\NUL ECHO Drive N: exists.

See either result0.htm  or 
result1.htm .

Although this behavior deviates from that of other drives, it is
consistent with the behavior of MS-DOS 6.22 using MSCDEX. There is
the possibility that correcting this issue has the potential to break
compatibility with any program that may rely on this behavior.

Issue 2:

Testing for the existence of a non-existing drive returns unreliable
results. This seems reproducible based on the current working directory
when the test is performed. For each test, a copy of the TEST.BAT 
 was
placed in the current working directory.

result0.htm  was run with 
the current drive and directory on an internal
local drive (C:). It incorrectly shows that the non-existing drive (P:)
was found.

result1.htm  was run with 
the current drive and directory on an remote
network share (N:). It correctly shows that the non-existing drive (P:)
was not found.

Switching back and forth between drive C: and N: and running the
TEST.BAT  consistently 
produces the same results.___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel