Eric Auer points us to a page of MS-DOS errorlevels:
This explains the errorlevels of FIND, CHKDSK, CHOICE, DEFRAG, DELTREE, DISKCOMP, DISKCOPY, FC, FIND, FORMAT, KEYB, MSAV, REPLACE, RESTORE, SCANDISK, SETVER, XCOPY.
Because MS tools often only use very few different errorlevels, I vote for a command line switch "return MS style errorlevels" for tools like CHKDSK or FORMAT. Without that command line switch, "more verbose" FreeDOS style errorlevels would be allowed.
- FIND: 0 found, 1 none found, 2 search not completed
- CHKDSK: 0 drive okay, 255 any error
- CHOICE: 0 if aborted, 255 on error, choice value otherwise
- DEFRAG: 0 success, 1 internal error, 2 disk too full to defrag, 3 aborted by user, 4 general error, 5 read error, 6 write error, 7 FAT allocation error, 8 "memory error", 9 out of memory
- DELTREE: 0 success, 1 error
- DISKCOMP: 0 disks are the same, 1 differences found, 2 user aborted with ^C, 3 critical error abort, 4 initialization error (e.g. no such drive?)
- DISKCOPY: 0 success, 1 non-fatal r/w error, 2 user aborted with ^C, 3 critical error abort, 4 initialization error
- FORMAT: 0 success, 3 user aborted with ^C, 5 user did not confirm, 4/others signal various fatal errors.
- KEYB: 0 success, 1 invalid keycode/charset/syntax, 2 keyboard definition file bad or missing, 4 error when communicating with keyboard or monitor, 5 requested charset has not been prepared.
- MSAV: 86 virus found
- REPLACE: 0 success, 1 wrong DOS version, 2 source files not found, 3 source or dest. path not found, 5 could not replace files (access violation), 8 not enough memory, 11 syntax error.
- RESTORE: 0 success, 1 files not found, 3 aborted by ^C, 4 aborted with error
- SCANDISK: 0 disk okay, 1 syntax error, 2 unexpected out of memory error, 3 aborted by user, 4 all logical checks but not all surface scans done (unless command line option already told to skip surface scan alltogether), 254 errors found but corrected, 255 errors found but not all corrected.
- SETVER: 0 success, 1 syntax error, 2 file not found, 3 out of memory, 4 invalid version number format, 5 entry in version table not found, 6 setver binary not found, 7 invalid drive, 8 too many command line args, 9 missing command line parameters, 10 error reading setver binary, 11 setver binary corrupt, 12 setver binary has no version table, 13 version tible full, 14 error writing the changed binary.
- XCOPY: 0 success, 1 no files found to copy, 2 aborted by ^C, 4 initialization error (not enough memory or disk space, invalid drive, or syntax error), 5 disk write error.
Cheats:REM | %comspec% /c choice /c:delay /t:d,2 > nul
orchoice /t\,2 /c\ wait >nul <aux
users.cybercity.dk/~bse26236/batutil/help/EMM386S.HTM tells that ROM=... would mean "shadow rom here". So indeed, it is different from X=... which excludes areas from remapping.
users.cybercity.dk/~bse26236/batutil/help/FORMAT_S.HTM explains FORMAT /C ... Without that switch, FORMAT would copy the list of bad sectors from previous disk contants and skip them in surface scan. The new /C option forces re-scanning them. FreeDOS FORMAT always discards the bad cluster list and always scans all or nothing of the surface. [TODO ITEM...!]
HIMEM has an option /A20CONTROL:OFF which means "if A20 found on when HIMEM started, leave A20 on all the time".
It also has /SHADOWRAM:ON which means "do not attempt to disable ROM shadowing if < 2 MB RAM". This implies that if you have < 2 MB RAM, HIMEM would normally try to enable the "memory hole" in the UMB area, to get more free XMS (but shadowing is impossible then).
Thanks go to David of wishmaster.at for finding this site. He has also told me about the device information word of MS ANSI: It is 0xc053 - while NANSI only has 0x8013. The difference: IOCTL supported and "EOF on input". I think I can simply set those 2 flags when /P mode of NANSI is on, BUT somebody must first tell me what "EOF on input" is supposed to mean. Thanks!
Maybe it is that one (see RBIL 61 table 02597, device driver request header) ... (and see table 02595, values for device driver command code) ... 6 "input status" (PS: MS shell or kernel expects command 0x0a, output status, to be supported, this is why I had to set that one to "chain" in the last MORE$ update) ... no idea if 0x10, output until busy is used ... Int 21.4406 explains: reports "BUSY" if input is "at EOF", where "at EOF" means "EOF char 0x1a encountered". Guess only cooked mode, not raw mode should ever return "at EOF"?
Explanation for "output status": DOS 2+ files are even ready if disk full or no disk in drive. Verrry useful. Probably meant to block only for serial console stdout case?
From my experience, "output status" is queried before an actual char device write happens. Guess MS kernel / shell would stay in idle loop until output is no longer busy if "busy" status returned?
Matthias Paul replies:
[.. I vote for a command line switch "return MS style errorlevels" ..] Nice idea in general, but for maximum compatibility with /existing/ batchjobs, in some sense I would like to suggest just the opposite:
Try to implement MS-DOS/PC DOS tools errorlevels as close as possible, and in case no MS-DOS errorlevels are known/ documented, try to follow DR-DOS tools, instead.
If a user wants more specific error levels, she should add a command line parameter /R (as for "return code"), which will, depending on the specific utility, return more detailed but for the most part arbitrary error levels in the range 0..255.
BTW. Since 1997, several of the DR-DOS tools have been enhanced to support just this option /R, although a list of the more detailed error levels has not been published up to now, unfortunately. But in some cases (for example MEMMAX), the scheme is easy enough to derive reading the help screen and carrying out a few tests. I chosed /R in favour to /E (as for "errorlevel"), since there have been no naming conflicts in the tools I expected to get enhanced with this feature eventually, and /E was already in use by some of the tools for other purposes. However, you will always run into conflicts in case this idea would get extended to a broad range of utilities, so I suggest to choose /E as a second choice in case /R is already used up or is used for another purpose, either in the corresponding FreeDOS tool itself, or in the MS-DOS/PC DOS/DR-DOS/PTS-DOS tools it resembles. This way we will attempt to keep this as uniform as possible.
I haven't cross-checked your list of error levels at the moment (sorry, no time for it right now), but over the years I have collected a quite long list of observed errorlevels myself. My list not only lists the officially documented return codes of MS-DOS, PC DOS and DR-DOS, but also many (for sure not all) of the undocumented codes, including some PTS-DOS, OS/2 and NT ones, whereever this was applicable. Maybe this list could be useful to whoever jumps on this idea as well. You can find it as part of the MPDOSTIP.ZIP package downloadable on my (very outdated - sic) web-page to be found via my signature below. Meanwhile the material is also floating around on various other German web sites (sometimes with my permission, but most often without any authorization...)
The list is in German language, but I think, the list of errorlevels is easy enough to translate. But if someone has specific questions in regard to it, feel free to ask and I will try to clear up the issue as my time allows. Of course, if someone is willing to compile a "master list" from the various sources in the net in English language and wants to include my list, that's fine with me as well.