roelandjansen / pcmos386v501

PC-MOS/386 v5.01 and up, including cdrom driver sources.
GNU General Public License v3.0
418 stars 60 forks source link

Command interpreter does not exit with proper errorlevel #95

Open dgorski opened 4 years ago

dgorski commented 4 years ago

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?

stsp commented 4 years ago

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.

dgorski commented 4 years ago

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).

roelandjansen commented 4 years ago

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 notifications@github.com 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 .

stsp commented 4 years ago

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]
dgorski commented 4 years ago

Awesome! How do I build?

stsp commented 4 years ago

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.

dgorski commented 4 years ago

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

dgorski commented 4 years ago

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?

stsp commented 4 years ago

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

stsp commented 4 years ago

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

dgorski commented 4 years ago

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 commented 4 years ago

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
stsp commented 4 years ago

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.

the-grue commented 4 years ago

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 commented 4 years ago

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

dgorski commented 4 years ago

@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.

stsp commented 4 years ago

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.

the-grue commented 4 years ago

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.

stsp commented 4 years ago

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

dgorski commented 4 years ago

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

the-grue commented 4 years ago

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.