Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

C's system() & COMMAND.COM (Developers)

posted by Rugxulo(R) Homepage, Usono, 01.11.2014, 23:32

> Unfortunately, INT 2Eh has this problem (quoting from the link provided):
> "results are unpredictable if invoked by a program run from a batch file
> because this call is not reentrant and COMMAND.COM uses the same internal
> variables when processing a batch file".

Yes, I know, but I still thought it was worth mentioning, at least for completeness. Besides, obviously there are many DOSes (not just from MS) and many shells, so they can't all have the same limitations (e.g. see PATH Not Limited to 128 Characters).

> I really don't think there's a way to do what you're trying to do and have
> it return consistent results. E.g., I'm not sure if/how ErrorLevels are
> even returned by internal commands (or even if internal commands terminate
> with an INT 20h or INT 21.4C).

To quote the current Regina Rexx website (even though he doesn't support the DOS port anymore):

"Regina and Win95/98/Me

Due to a bug in the Windows 9x and Me command processor; COMMAND.COM, all calls to operating system commands from within Regina will ALWAYS return a zero return code. This is because COMMAND.COM always returns a zero return code. If you really need to be able to detect non-zero return codes from operating system commands, I recommend you get JP Software's 4DOS or 4NT."

> I'm not sure exactly how batch files
> terminate, either, but what your system() call should return is the
> ErrorLevel of the batch file itself (which doesn't really exist AFAIK), and
> not just the ErrorLevel of the last command the batch file issued.

Some shells (e.g. DR-DOS 7.03) let you "EXIT" from a .BAT with an errorlevel. And while I don't think FreeDOS' FreeCOM supports that, it does have an unusual feature where errorlevel can be treated like an environment variable (instead of forcing a long descending cascade of "if errorlevel" statements).

Obviously the problem here is that no shell properly runs on all these variants. So you'd have to port and improve one (e.g. FreeCOM, which is GPL) yourself if it's important enough to you.

 

Complete thread:

Back to the forum
Board view  Mix view
15192 Postings in 1365 Threads, 250 registered users, 10 users online (0 registered, 10 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum