Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Existence in question #61

Open
shidel opened this issue Dec 3, 2021 · 8 comments
Open

Existence in question #61

shidel opened this issue Dec 3, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@shidel
Copy link

shidel commented Dec 3, 2021

Hi, working on RC5 I noticed an interesting bug. The bug may or may not be in FreeCOM. I don't have the time to try and run it down right now. But so I don't forget about it, i'll file a bug report. If I recall, maybe I circle back to it later.

VirtualBOX, Latest Kernel, Latest FreeCOM (WATCOM/XSWAP/EN), Networking. For this example also with EtherDFS running.
A: Floppy Image, C: Hard Disk, D: CDROM, N: Mountd Network Share. No other Drives.

When booting the latest kernel and FreeCOM (Watcom) I get the following inconsistencies with EXIST...
(Repeat for each A,C,D,E,N,X. Drives E and X do not exist)

if exist a:\command.com echo yes
COMMAND.COM on all drives but N:. All report as they should. A, C, D = yes. E,N,X show nothing.

if exist a:\freedos\bin\command.com echo yes
True for only A & D; All report as they should.

if exist a:\freedos\nul echo yes
True for only A&D; All report as they should

Now this is where we get weird.
if exist a:\nul echo yes
All return yes. Ummm. ?

Here is a fun one...
if exist c:\command.com echo yes
( prints yes )
if exist c:\command.com
( prints yes, again )
if exist c:\nul
( prints Bad command or filename - "-". )

Now, when I boot the RC5, LiveCD. An image is mapped to drive A:. And a RamDrive is mapped to R:
Exhibits same behavior as mentioned earlier. Plus some new stuff.
if exist A:\nul echo yes
( prints yes, as it should )
if exist B:\nul echo yes
( returns nothing, as it should )

I think there were some other strange results, but I forget what they were and can't seem to replicate them at present.

On a side note...

dir X:\  reports -- Drive not found.
dir X:   reports -- File not found.

@PerditionC
Copy link
Contributor

Interesting, looks like some issues with redirected drives. I will have to do some testing and comparisons. What software did you use to map the network drive N: ?

@PerditionC
Copy link
Contributor

Just reread, etherdfs.

@shidel
Copy link
Author

shidel commented Dec 3, 2021

It also does the same thing when booting the installed RC5. Which does not have EtherDFS. Only Kernel, FreeCOM, CD Driver Stuff, and Packet Driver (Since installed on VirtualBox), Jemm and some other common stuff. What I should do is boot the installed RC in emergency mode without any drivers and retry. That won't take long. I'll do it right now....

Hmmm, It seems even worse.

VirtualBox, Only Kernel and FreeCOM, no other drivers, no CD or Floppy attached. Only Drive A&C exist and no disk in drive A. From the command line (not in a batch file) typing the following sequence yields some strange results.

I don't recall of leaving out the "what to do" portion may or may not be a syntax error. Other than this test, I've never tried it. It would never do something useful. It "could" set an errorlevel, but that's pointless. Just use the rest of the statement to do something at that point.

if exist x:\freedos\nul echo yes                               -- yes (wrong, should not print anything)
lf exist x:\nul                                                -- Bad command or filename - "[box character]".  (wrong)
if exist x:\nul echo yes                                       -- yes (wrong)
if exist x:\                                                   -- (no output)
if exist x:\nul echo yes                                       -- yes (wrong)        
if exist x:\nul                                                -- Bad command or filename - "6". (wrong)
if not exist x:\freedos\nul echo no                            -- (no output, wrong, but is the opposite of without NOT)
if exist c:\nodir\null echo yes                                -- (no output, correct)
if exist c:\nodir\null                                         -- (no output, maybe syntax error)
if exist c:\freedos\bin\command.com echo yes                   -- yes (correct)
if exist c:\freedos\bin\command.com                            -- yes (wrong on so many levels)
if exist x:\anything.exe echo yes                              -- (no output, correct)

dir x:\     -- Invalid drive X:. (correct)
dir x:      -- File not found. - 'x:' (while true and of little importance, it is still the wrong error)

if "A" == "A" echo yes      -- yes (correct)
if "A" == "A"               -- IF: Missing command (correct, a syntax error, at least not yes or random BC error)

When doing repeated "if exist x:\nul" statements (just using history) that produce the "Bad Command" error over and over again consecutively, the quoted command is always a single character and changes each time.

So, for the exist bug, I think it most likely is several different bugs showing up in the same general area.

  • The missing "command" portion yields random command not found errors and sometimes repeats a prior command and seems to very based on whether or not the item exists.
  • Testing for NUL on a non-existing drive should always equate to false.
  • I think the incorrect dir error message is separate and of little to no importance.

@andrewbird
Copy link
Contributor

I just tried this in FreeDOS 1.2 (under dosemu2) and the problem seems to be there too, at least in the simple case of

C:\>ver /r

FreeCom version 0.84-pre2 XMS_Swap [Aug 28 2006 00:29:00]
DOS version 7.10
FreeDOS kernel 2042 (build 2042 OEM:0xfd) [compiled May 11 2016]

C:\>if exist x:\nul echo yes
yes

C:\>

I also tried the same thing under MSDOS 6.22 which gives the expected result

C:\>ver

MS-DOS Version 6.22


C:\>if exist x:\nul echo yes

C:\>

@shidel
Copy link
Author

shidel commented Dec 3, 2021

Good to know it's not something new that happened as a result of the compiler related changes. :-)

@PerditionC PerditionC added the bug Something isn't working label Dec 3, 2021
@andrewbird
Copy link
Contributor

I've just written a little test for the dosemu2 test suite based on some of your examples. It does some tests on a non existent, a local FAT, and a network redirected drive. I've tried it out on DR-DOS 7.01, MS-DOS 6.22, and FDPP current git HEAD to establish that the semantics are correct. Each subtest should print 'xx_True'

On FreeDOS 1.2 I get only one failure, the one I mentioned earlier

if not exist X:\NUL                echo 01_True                                 
(no output)                                                                     

On current FreeDOS GIT HEAD kernel and GIT HEAD freecom, both compiled here with GCC and I see no failures.

C:\>ver /r                                                                      
                                                                                
FreeCom version 0.85a - GNUC - XMS_Swap [Dec  3 2021 19:10:01]                  
DOS version 7.10                                                                
FreeDOS kernel - GIT (build 2043 OEM:0xfd) [compiled Dec  3 2021]               
                                                                                
C:\>testit                                                                      
C:\>rem X: is a non-existent drive                                              
C:\>if not exist X:\ANYTHING.EXE       echo 00_True                             
00_True                                                                         
C:\>if not exist X:\NUL                echo 01_True                             
01_True                                                                         
C:\>if not exist X:\FAKEDIR\NUL        echo 02_True                             
02_True                                                                         
C:\>rem D: is a FAT(local) drive                                                
C:\>D:                                                                          
D:\>cd \                                                                        
D:\>mkdir ISDIR                                                                 
D:\>echo hello > ISDIR\EXIST.TRU                                                
D:\>if exist D:\NUL                    echo 03_True                             
03_True                                                                         
D:\>if not exist D:\EXIST.NOT          echo 04_True                             
04_True                                                                         
D:\>if not exist D:\NODIR\NUL          echo 05_True                             
05_True                                                                         
D:\>if not exist D:\NODIR\ANYTHING.EXE echo 06_True                             
06_True                                                                         
D:\>if exist D:\ISDIR\EXIST.TRU        echo 07_True                             
07_True                                                                         
D:\>if not exist D:\ISDIR\EXIST.NOT    echo 08_True                             
08_True                                                                         
D:\>rem C: is an MFS(network redirected) drive                                  
D:\>C:                                                                          
C:\>cd \                                                                        
C:\>mkdir ISDIR                                                                 
C:\>echo hello > ISDIR\EXIST.TRU                                                
C:\>if exist C:\NUL                    echo 09_True 
09_True                                                                         
C:\>if not exist C:\EXIST.NOT          echo 10_True                             
10_True                                                                         
C:\>if not exist C:\NODIR\NUL          echo 11_True                             
11_True                                                                         
C:\>if not exist C:\NODIR\ANYTHING.EXE echo 12_True                             
12_True                                                                         
C:\>if exist C:\ISDIR\EXIST.TRU        echo 13_True                             
13_True                                                                         
C:\>if not exist C:\ISDIR\EXIST.NOT    echo 14_True                             
14_True                                                                         
C:\>rem end                                                                     

There was some kernel work done in this area see FDOS/kernel@6ada304 and FDOS/kernel@c69638de, and includes tests, The current kernel/freecom behaves identically in my tests to both MS-DOS 6.22 and DR-DOS 7.01.

ajb@polly:/clients/common/dosemu2.git$ test/test_dos.py test_command_com_keyword_exist
Test DR-DOS-7.01 Command.com keyword exist                                       ... ok (  2.41s)
Test FR-DOS-1.20 Command.com keyword exist                                       ... FAIL (one or more subtests)
    [Subtest 01]                                                                 ... FAIL
Test FR-DOS-GIT  Command.com keyword exist                                       ... ok (  1.49s)
Test MS-DOS-6.22 Command.com keyword exist                                       ... ok (  2.67s)
Test PP-DOS-GIT  Command.com keyword exist                                       ... ok (  2.10s)

======================================================================
FAIL: test_command_com_keyword_exist (__main__.FRDOS120TestCase) [Subtest 01]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/test_dos.py", line 3049, in test_command_com_keyword_exist
    self.assertRegex(results, s)
AssertionError: Regex didn't match: '(?m)^01_True.*' not found in 'testit.bat\r\nC:\\>rem X: is a non-existent drive\r\nC:\\>if not exist X:\\ANYTHING.EXE       echo 00_True\r\n00_True\r\nC:\\>if not exist X:\\NUL                echo 01_True\r\nC:\\>if not exist X:\\FAKEDIR\\NUL        echo 02_True\r\n02_True\r\nC:\\>rem D: is a FAT(local) drive\r\nC:\\>D:\r\nD:\\>cd \\\r\nD:\\>mkdir ISDIR\r\nD:\\>echo hello > ISDIR\\EXIST.TRU\r\nD:\\>if exist D:\\NUL                    echo 03_True\r\n03_True\r\nD:\\>if not exist D:\\EXIST.NOT          echo 04_True\r\n04_True\r\nD:\\>if not exist D:\\NODIR\\NUL          echo 05_True\r\n05_True\r\nD:\\>if not exist D:\\NODIR\\ANYTHING.EXE echo 06_True\r\n06_True\r\nD:\\>if exist D:\\ISDIR\\EXIST.TRU        echo 07_True\r\n07_True\r\nD:\\>if not exist D:\\ISDIR\\EXIST.NOT    echo 08_True\r\n08_True\r\nD:\\>rem C: is an MFS(network redirected) drive\r\nD:\\>C:\r\nC:\\>cd \\\r\nC:\\>mkdir ISDIR\r\nC:\\>echo hello > ISDIR\\EXIST.TRU\r\nC:\\>if exist C:\\NUL                    echo 09_True\r\n09_True\r\nC:\\>if not exist C:\\EXIST.NOT          echo 10_True\r\n10_True\r\nC:\\>if not exist C:\\NODIR\\NUL          echo 11_True\r\n11_True\r\nC:\\>if not exist C:\\NODIR\\ANYTHING.EXE echo 12_True\r\n12_True\r\nC:\\>if exist C:\\ISDIR\\EXIST.TRU        echo 13_True\r\n13_True\r\nC:\\>if not exist C:\\ISDIR\\EXIST.NOT    echo 14_True\r\n14_True\r\nC:\\>'

----------------------------------------------------------------------
Ran 5 tests in 10.718s

FAILED (failures=1)

So in summary, I do see a problem with Freedos 1.2, but not in current git.

@shidel
Copy link
Author

shidel commented Dec 4, 2021

Hi @andrewbird,

You left a type of EXIST failure. The invalid syntax and failure test.

When you do these consecutively, the first should say yes. But, the second should do NOTHING. Or, at least to be consistent with MS-DOS provide an error. This seems to happen with just IF EXIST and not with if A == B.

if exist c:\freedos\bin\command.com echo yes                   -- yes (correct)
if exist c:\freedos\bin\command.com                            -- yes (wrong on so many levels)

Both report YES. Which is very wrong. The second has not command. I seems to be left over from before.

If the "COMMAND" portion is left off on a non-existing drive, it gives a bad command error referencing a random character.

@andrewbird
Copy link
Contributor

Both report YES. Which is very wrong. The second has not command. I seems to be left over from before.

Agreed, and seems to be a regression as FD 1.2 seems to handle this better.

Current git

C:\>dir
 Volume in drive C is IR DXXXXS C
 Directory of C:\

TMP                  <DIR>  12-04-21  5:50p
TESTIT   BAT           964  12-04-21  5:50p
COMMAND  COM        85,830  12-04-21  5:50p
KERNEL   SYS        52,992  12-04-21  5:50p
FDAUTOEM BAT           727  12-04-21  5:50p
SHARE    COM         3,984  12-04-21  5:50p
VERSION  BAT            17  12-04-21  5:50p
DOSEMU               <DIR>  12-03-21  2:42p
FDCONFIG SYS           344  12-04-21  5:50p
ISDIR                <DIR>  12-04-21  5:50p
         7 file(s)        144,858 bytes
         3 dir(s)     94,658 Mega bytes free
C:\>if exist c:\version.bat echo yes
yes
C:\>if exist c:\version.bat
yes
C:\>

FD 1.2

C:\>dir
 Volume in drive C is IR DXXXXS C
 Directory of C:\

TMP                  <DIR>  12-04-21  5:54p
TESTIT   BAT           964  12-04-21  5:54p
COMMAND  COM        66,945  01-22-17  3:13p
KERNEL   SYS        46,685  01-22-17  3:13p
FDAUTOEM BAT           727  12-04-21  5:54p
SHARE    COM         6,320  03-21-20 11:45a
VERSION  BAT            17  12-04-21  5:54p
DOSEMU               <DIR>  12-03-21  2:42p
FDCONFIG SYS           344  12-04-21  5:54p
ISDIR                <DIR>  12-04-21  5:54p
         7 file(s)        122,002 bytes
         3 dir(s)     94,658 Mega bytes free
C:\>if exist c:\version.bat echo yes
yes
C:\>if exist c:\version.bat
IF: Missing command
C:\>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants