Menu

#140 cmd: call internal command shouldn't set the %errorlevel% variable?

open
nobody
None
5
2024-08-13
2015-11-08
No

Steps to reproduce:

1) create (with your favorite test editor) a file called test.bat with the command

exit /b 1

2) open a command line interpreter and run the script by using:

call test.bat

3) run the command

echo %errorlevel%

Under FreeDoS 1.1 you will get a 0

But in Windows 7 it returns 1!

(I don't have a true MS-DOS to test this!)

That I think is the most sensitive behavior, since many times you need to know the exit status of the called script). However this NOT documented
in MSD (https://technet.microsoft.com/en-us/library/bb490873.aspx) which says nothing about %errorlevel% !!

I have also reported this at React OS (which appears to have the same problem, it returns 0)

https://jira.reactos.org/browse/CORE-10495

(greetings there from Jim Tabor to James Hall )

Discussion

  • Anthony Williams

    AFAIK, no, classic MS-DOS never supported that functionality. 4DOS might, but I can't remember. I do think DR-DOS 7.03's shell supported it, but again, it's non-standard. A simple utility could be whipped up in either asm or C that could easily emulate this functionality for you. Oops, actually, FreeCOM already had such an test utility, see https://sourceforge.net/p/freedos/svn/HEAD/tree/freecom/trunk/tests/errlvl.c ,

     
  • Pablo De Napoli

    Pablo De Napoli - 2015-11-09

    This feature would be useful in order to know the exit status of a batch script (not for generating a specific exit status. as the errlvl utility does). If MS-DOS ver supported that functionality, it might not be a bug.

     
  • Pablo De Napoli

    Pablo De Napoli - 2015-11-09

    I've tested 4DOS and it seems that it doen't support this feature. Confirmed.

     
  • fritz.mueller

    fritz.mueller - 2024-08-13

    Just for info:
    ReactOS seems to have fixed this.
    https://jira.reactos.org/browse/CORE-10495

     

Log in to post a comment.