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

Internal commands don't set ERRORLEVEL #28

Open
francescosacco opened this issue Sep 8, 2020 · 4 comments
Open

Internal commands don't set ERRORLEVEL #28

francescosacco opened this issue Sep 8, 2020 · 4 comments
Labels
bug Something isn't working follow up Additional follow up still to be done

Comments

@francescosacco
Copy link
Contributor

Internal commands should set the ERRORLEVEL, just like normal commands. However, it doesn't happen as we can see below.

image

@andrewbird
Copy link
Contributor

@PerditionC presumably this can be closed now?

@PerditionC
Copy link
Contributor

Yes, I left it open because I wanted to see if a similar fix was still needed for comcom

@andrewbird
Copy link
Contributor

I don't have much recent experience with DOS batchfiles so the example below may be flawed, but I just tested with Dosemu2 and MS-DOS 6.22 and it seems that it doesn't report the success/fail of internal commands. With an external command the success / fail worked as expected.

@echo off

rem External command that succeeds
rem ISEMU

rem External command that fails (due to configuration)
rem FOSSIL

rem Internal command (X: doesn't exist)
DIR X:

if ERRORLEVEL 1 goto error

:isokay
echo okay
goto done

:error
echo with error

:done
C:\>mytest
Invalid drive specification
okay

@PerditionC PerditionC added the follow up Additional follow up still to be done label May 27, 2021
@PerditionC PerditionC added the bug Something isn't working label Jun 19, 2021
@dgorski
Copy link
Contributor

dgorski commented Mar 8, 2022

Related to #22 - exit always returns zero from a subshell, but exiting a batch file (as long as it doesn't end with exit) returns the errorlevel. This is specific to a non-permanent shell (subshell).

exit should return the errorlevel to the calling shell.

'exit' probably shouldn't do anything at all for a /P shell (including alter the errorlevel).

C:\>ver /r

FreeCom version 0.85a - WATCOMC - XMS_Swap [Jul 10 2021 19:28:06]
DOS version 7.10
FreeDOS kernel 2043 (build 2043 OEM:0xfd) [compiled May 14 2021]
C:\>type test.bat
@echo test.bat
@c:\utils\err 2
@if "%1"=="exit" exit

C:\>command /c test.bat
test.bat
C:\>echo %errorlevel%
2
C:\>command /c test.bat exit
test.bat
C:\>echo %errorlevel%
0
C:\>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working follow up Additional follow up still to be done
Projects
None yet
Development

No branches or pull requests

4 participants