pcmos386v501 icon indicating copy to clipboard operation
pcmos386v501 copied to clipboard

Command interpreter does not exit with proper errorlevel

Open dgorski opened this issue 4 years ago • 21 comments

Hi,

I'm using software that swaps out and creates a subshell (using COMSPEC) to run batch files. These files return errorlevels back to the software to inform the result of the batch run.

Under PCMOS the result is either 0 or 43 depending on if the "exit" command is used, or if the batch file reaches the end. It does not seem to matter what the errorlevel was prior to exist, the return is either 43 or 0.

Under other command.com implementations, the current errorlevel is returned as the result of command.com exiting (that is, it returns the result of the last command).

The use of $COMPAT$ does not seem to matter.

Any chance there is an easy way to adjust the command interpreter for this?

dgorski avatar Apr 29 '20 17:04 dgorski

I think many command.com's are broken on that, even FreeCOM IIRC. Maybe you can just run another command.com? 4DOS is the most compatible of all times. comcom32 is minimalistic, but supports that feature.

stsp avatar Apr 29 '20 21:04 stsp

Yep, FreeCOM is also broken in a similar way (it is hard coded to always return zero no matter what).

This was one of the reasons I went looking for a different DOS-compatible OS (and found PCMOS!)

Unfortunately once I figured out how the PCMOS worked and got everything situated, I found out that this is also broken in PCMOS. (in a slightly different way than in FreeCOM).

Unfortunately I can use the 4DOS shell on FreeDOS to mitigate this problem, but I've not been very successful using an alternative shell on PCMOS. 4DOS is very confused under PCMOS (it seems to lose the ability to traverse the filesystem).

  • Darrin

dgorski avatar Apr 30 '20 02:04 dgorski

thanks for the heads up. I am quite busy with a carve-out mogration as parts of the company were sold and that at least will take it to the end of the year.

Regarding the return code -- if it's ever being taken up, we should follow the original command.com specs.

On Thu, Apr 30, 2020 at 4:07 AM Darrin M. Gorski [email protected] wrote:

Yep, FreeCOM is also broken in a similar way (it is hard coded to always return zero no matter what).

This was one of the reasons I went looking for a different DOS-compatible OS (and found PCMOS!)

Unfortunately once I figured out how the PCMOS worked and got everything situated, I found out that this is also broken in PCMOS. (in a different way than in FreeCOM).

Unfortunately I can use the 4DOS shell on FreeDOS to mitigate this problem, but I've not been very successfuly using an alternative shell on PCMOS. 4DOS is very confused under PCMOS (it seems to lose the ability to traverse the filesystem).

  • Darrin

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/roelandjansen/pcmos386v501/issues/95#issuecomment-621569465, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACNIXVRLHXTWZCGP73OTQNDRPDMP7ANCNFSM4MT5VFAQ .

roelandjansen avatar Apr 30 '20 07:04 roelandjansen

Maybe you are looking for something like this:

diff --git a/SOURCES/src/latest/MOXCPCOR.ASM b/SOURCES/src/latest/MOXCPCOR.ASM
index ec1596d..838c163 100644
--- a/SOURCES/src/latest/MOXCPCOR.ASM
+++ b/SOURCES/src/latest/MOXCPCOR.ASM
@@ -3540,7 +3540,7 @@ eec1:
 ee2:
        true?   [copt]                  ; if the command was from a /c option, quit,
        ljne    issueprompt             ; else recycle to the command prompt.
-       xor     al,al
+       mov     al,[errlvl]
        mos     quit
 ee4:                                   ; for null line entry
        true?   [batch]

stsp avatar Apr 30 '20 10:04 stsp

Awesome! How do I build?

dgorski avatar Apr 30 '20 21:04 dgorski

I build with build.sh script in SOURCES/src. But its basically my own build environment, not sure if you can get it to work. "Official" way is different, maybe someone else will tell how.

stsp avatar Apr 30 '20 21:04 stsp

I'm running that now, will see what I get! Thanks.

dgorski avatar Apr 30 '20 21:04 dgorski

I ran a build (a few actually) with "build.sh" in SOURCE/src but while it DOES build $$SHELL.SYS, it does not build COMMAND.COM ... at least not anywhere I can find.

I read somewhere about the "old" vs "new" way to do command.com, so I tried using the resulting $$SHELL.SYS as a command.com, but that doesn't work...

Any ideas on how to build COMMAND.COM?

dgorski avatar Apr 30 '20 23:04 dgorski

Try using previous command.com. I think my patch would change only $$shell.sys

stsp avatar May 01 '20 00:05 stsp

I have added PR #97 that will do everything for you (including command.com) with a script.

stsp avatar May 01 '20 11:05 stsp

So I switched to the old-style command.com (OLDCMD.BAT) and used the modified $$shell.sys from my trunk build (via build.sh in SOURCES/src). Unfortunately, I get "Improper MOS Version" on boot.

Not sure if that's coming from SHELL$$.SYS when the kernel loads it, or COMMAND.COM when the shell is invoked, but one of them is not happy.

Will look at req 97 above. Thanks!

dgorski avatar May 01 '20 16:05 dgorski

This is a little easier to build + run. My system doesn't like the --Fdrive_c $BOOTDIR so I had to wire up drive_c by hand. Unfortunately, this still doesn't work for me.

I suspect the old COMMAND.COM is doing something the newer $$SHELL.SYS (or the kernel) no longer supports.

Did this work on your build system? Is the build of command.com lost to time? (I didn't see any references in any of the makefiles)

Here's what happens when I boot the newly built MOS from SOURCE/src/latest

$ ( cd ~/.dosemu ; mv drive_c old_c ; ln -s /files/pcmos386v501/SOURCE/src/latest drive_c )
$ dosemu
Note that DOS needs 25 lines. You might want to enlarge your window before starting dosemu.

█▀▀█ █▀▀▀     ██▄██ █▀▀█ █▀▀▀ (R)                             ▒▒▒▒▒▒██████████
█▀▀▀ █    ▀▀▀ █ ▀ █ █  █ ▀▀▀█                                 ▒▒    ██▒▒    ██
▀    ▀▀▀▀     ▀   ▀ ▀▀▀▀ ▀▀▀▀       Modular Operating System  ▒▒    ██▒▒    ██
════════════════════════════════════════════════════════════  ▒▒▒▒▒▒▒▒▒▒██████
PC-MOS is a registered trademark of The Software Link, Inc.

(c) Copyright 1987-1992 The Software Link, Incorporated               rel 5.02
All rights reserved worldwide                                      X0-X0X0X0X0


Internal error #Extended Service xx no longer supported

dgorski avatar May 04 '20 18:05 dgorski

My system doesn't like the --Fdrive_c $BOOTDIR

But does the dosemu version check pass? Please show the output of dosemu --version.

Did this work on your build system?

I didn't try with my asm patch in that thread, but without it - yes, it works. Can you try w/o the patch, just to make sure we have the same starting point?

Note that DOS needs 25 lines.

Your dosemu build feels very badly. It tries terminal, but terminal is too small. Can you install the pre-packaged dosemu? It will start in a separate window, not in terminal then. And we will have the similar builds to start with.

stsp avatar May 04 '20 19:05 stsp

Hi @dgorski !

If I remember correctly, command.com is just a stub to reload $$shell.sys. Here is the relevant build information from /SOURCES/src/latest/BOSMAKE.BAT

ren MOXCPTSK.COM COMMAND.COM

So command.com is actually moxcptsk.com in the makefile MAKEUTIL.MAK.

the-grue avatar May 05 '20 02:05 the-grue

Oh, and the XO stuff should actually be replaced by a valid serial number and automagically registered if your build completes successfully.

the-grue avatar May 05 '20 02:05 the-grue

@the-grue , Thanks, not sure how I missed that. I'll check on that for command.com (the build script was just pulling a pre-built one from that ZIP file). Regarding the serialno, as far as I can tell it did build correctly/completely - I didn't see any errors during the build and the build did complete.

@stsp , Yes, my dosemu version check passes, but dosemu complains about that --F option (should be a single maybe? I don't try mofiying it). Manually symlinking the build dir to ~/.dosemu/drive_c seemed workaround it.

$ dosemu --version
dosemu2-2.0pre8
Revision: 3695

$ rpm -qa | grep dosemu
dosemu2-2.0pre8-1.fc27.x86_64

PS - I run dosemu via a terminal window, all of my linux machines are headless (and remote). It complained about 25 lines because my default terminal windows are 24. I can run in 25 lines, no difference.

dgorski avatar May 05 '20 15:05 dgorski

a pre-built one from that ZIP file).

It doesn't matter. What matters is $$shell.sys. You can even boot w/o command.com at all, its just that you won't be able to run command.com /C some_cmd But I updated the script, see #98

Yes, my dosemu version check passes, but dosemu complains about that --F option

OK, thanks for confirming. I digged through git log and found that --Fdrive_c is a recent addition, so the check is updated too. Hmm, it seems the log have recent mentions of MOS... updated the check to cover also those.

complained about 25 lines because my default terminal windows are 24.

Yes, but for me that was an indication that it can't create an X window. If its intentional then fine.

stsp avatar May 05 '20 15:05 stsp

Hope I didn't inject any confusion here. I assumed you were using my build scripts, which build a complete distro. I now see you are using dosemu, which I don't test against. I just do bare metal and virtual machines.

the-grue avatar May 05 '20 19:05 the-grue

But now you can test it by just running run.sh after a build. Much simpler than anything else. :)

stsp avatar May 05 '20 19:05 stsp

@the-grue - no problem. Can you elaborate on your build? Do you build on MOS?

dgorski avatar May 05 '20 19:05 dgorski

Yeah, pretty sure my build worked on MOS. To do the full build, you'll need Borland C++ 3.1 and Turbo Pascal 7 (if you want to rebuild the help program but not required). Run makeall.bat with some parameters and it should build a full distribution into c:\distro and register it (no more 60 minute timeout). If you have a 1.44 MB floppy in drive A it will format it and create an installable disk image with the full 5.02 distro. This isn't required though if you just want the bits out of the c:\distro directory.

Honestly, I haven't touched this code since I added the CDROM driver to the distro, so if you want specifics or a tutorial it'll take me some time to get familiar with it again.

the-grue avatar May 05 '20 21:05 the-grue