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

Command interpreter does not exit with proper errorlevel #95

Open
dgorski opened this issue Apr 29, 2020 · 21 comments
Open

Command interpreter does not exit with proper errorlevel #95

dgorski opened this issue Apr 29, 2020 · 21 comments

Comments

@dgorski
Copy link

dgorski commented Apr 29, 2020

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
Copy link
Contributor

stsp commented Apr 29, 2020

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
Copy link
Author

dgorski commented Apr 30, 2020

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

@roelandjansen
Copy link
Owner

roelandjansen commented Apr 30, 2020 via email

@stsp
Copy link
Contributor

stsp commented Apr 30, 2020

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
Copy link
Author

dgorski commented Apr 30, 2020

Awesome! How do I build?

@stsp
Copy link
Contributor

stsp commented Apr 30, 2020

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
Copy link
Author

dgorski commented Apr 30, 2020

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

@dgorski
Copy link
Author

dgorski commented Apr 30, 2020

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
Copy link
Contributor

stsp commented May 1, 2020

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

@stsp
Copy link
Contributor

stsp commented May 1, 2020

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

@dgorski
Copy link
Author

dgorski commented May 1, 2020

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
Copy link
Author

dgorski commented May 4, 2020

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
Copy link
Contributor

stsp commented May 4, 2020

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
Copy link
Collaborator

the-grue commented May 5, 2020

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
Copy link
Collaborator

the-grue commented May 5, 2020

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

stsp added a commit to stsp/pcmos386v501 that referenced this issue May 5, 2020
As was pointed out, this is how command.com should be built.
@dgorski
Copy link
Author

dgorski commented May 5, 2020

@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 added a commit to stsp/pcmos386v501 that referenced this issue May 5, 2020
As was pointed out, this is how command.com should be built.
Also update dosemu revision check, as --Fdrive_c appears recent.
stsp added a commit to stsp/pcmos386v501 that referenced this issue May 5, 2020
As was pointed out, this is how command.com should be built.
Also update dosemu revision check, as --Fdrive_c appears recent.
@stsp
Copy link
Contributor

stsp commented May 5, 2020

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
Copy link
Collaborator

the-grue commented May 5, 2020

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
Copy link
Contributor

stsp commented May 5, 2020

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

@dgorski
Copy link
Author

dgorski commented May 5, 2020

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

@the-grue
Copy link
Collaborator

the-grue commented May 5, 2020

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.

roelandjansen added a commit that referenced this issue May 14, 2020
MAKEMOS.BAT: rename moxcptsk.com command.com [#95]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants