Re: [Freedos-user] command.com exit status

2020-04-26 Thread Darrin M. Gorski
>  Like what other command processors?

All of them.  MS-DOS, 4DOS (which is the one I've switched to for now,
despite it being a bit slow).  I'm running in QEMU on a pi4, so disk IO can
be painful.  4DOS.COM is 5 times larger than COMMAND.COM.

I ran these batch files under MS-DOS back in the day, and this was never
even a consideration. In fact it took me a while to figure out why this
didn't
work before I finally looked at the source. I might go so far as to call
this a
bug as it means FreeDOS does not provide an MS-DOS compatible
COMMAND.COM.

> In the old DOS days, COMMAND.COM *was* the calling shell things
> returned to, so not setting ERRORLEVEL was no surprise.  The
> assumption was that it was the boot shell.

Well, there is a reason for /P, not all instances of COMMAND are
permanent.  And if that's the case, the return code from a non permanent
shell could very well be interesting to whatever invoked it - even if that
was the permanent shell.

> What are your purposes?

It probably won't come as a surprise as it seems to be a common use for
FreeDOS, but I've resurrected my old DOS based BBS.  The BBS software
uses COMMAND.COM to sub-shell and run things like utility batch files and
external doors.  The result (ERRORLEVEL) of the batch/prog are returned
to the BBS for analysis.  FreeDOS command just blindly returns zero every
time, so it is unfortunately not usable.

>  I believe the alternative 4DOS shell can set an ERRORLEVEL, intended
> to be useful when it is invoked as a sub-shell.

Yep,  After sending this I went to look for alternatives.  4DOS does in fact
behave properly, but I was hoping not to have to resort to that.  It's
slick but
it's also much bigger and thus slower.

I asked the question because I can not think of any reason not to return
ERRORLEVEL like every other shell does and I was puzzled when I saw
that it was a literal zero being returned, despite the global variable
"errorlevel" being available.

Another cool hack, if someone is actually interested in fixing
COMMAND.COM, would be to allow the internal command "exit" take an
argument, and set "errorlevel" to that value before exiting.  (no arg?
return(errorlevel), arg? return(arg) instead). I've have to resort to
writing
external utilities that set errorlevel before exiting in order to send
proper
codes back to the BBS.  All of the COMMAND.COMs that I've used simply
ignore any arguments to the 'exit' command (as is expected).

I would do these things myself but I have no idea how to set up an
appropriate development environment for compiling DOS commands.

Maybe I'll look into that a little more.

Thanks for your reply!

- Darrin
___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user


Re: [Freedos-user] command.com exit status

2020-04-26 Thread dmccunney
On Sat, Apr 25, 2020 at 8:24 PM Darrin M. Gorski  wrote:
>
> Wondering why FreeDOS COMMAND.COM doesn't exit with ERRORLEVEL like other 
> command processors.  main() in command.c ends with "return 0" where it should 
> really be "return errorlevel".

Like what other command processors?

> This way error codes are returned to the calling shell (or other program).

In the old DOS days, COMMAND.COM *was* the calling shell things
returned to, so not setting ERRORLEVEL was no surprise.  The
assumption was that it was the boot shell.  What might fail and
generate a meaningful ERRORLEVEL was the program you were running
*from* COMMAND.COM.

> For my purposes it is a requirement that the errorlevel is returned to the 
> calling shell/program.
> Any options?

What are your purposes?

What will the calling shell/program be to receive and take action
based on the ERRORLEVEL returned?  And under what circumstances might
COMMAND.COM exit with a non-zero ERRORLEVEL if it did set one?

I believe the alternative 4DOS shell can set an ERRORLEVEL, intended
to be useful when it is invoked as a sub-shell.

> - Darrin
__
Dennis


___
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user