Hi Ralf, > On Jun 5, 2023, at 5:06 PM, Ralf Quint <freedos...@gmail.com> wrote: > > On 6/5/2023 1:56 AM, jer...@shidel.net <mailto: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/ >> <https://fd.lod.bz/redist/testing/devNUL/> and >> >> bug report at https://github.com/FDOS/freecom >> <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