REBOL3 tracker
  0.9.12 beta
Ticket #0001738 User: anonymous

Project:



rss
TypeBug Statusdismissed Date2-Nov-2010 08:43
Versionalpha 110 CategoryNative Submitted byBrianH
PlatformWindows Severityminor Prioritynormal

Summary On WINAPI main exe's: QUIT/return doesn't set the errorlevel
Description The number passed to QUIT/return should be used to set the errorlevel when the program exits. However, at this point R3 apparently doesn't set the errorlevel at all, leaving it the same number it was before the program ran.

The errorlevel should be set to 0 for a normal exit, or to the number passed to QUIT/return if that is used to quit. Note that the %errorlevel% in the example code below isn't a real environment variable, it is just a shortcut to see the internal errorlevel setting.
Example code
C:\Users\Brian\Downloads>r3-a110-3-1.exe

C:\Users\Brian\Downloads>echo %errorlevel%
1

Assigned ton/a Fixed in- Last Update15-Dec-2015 08:21


Comments
(0002763)
abolka
2-Nov-2010 19:42

The problem here is not in QUIT/return but in the method used to print the exit code. For "Console-mode" binaries, the above works just fine (as can be verified via the hostkit).

But "GUI-mode" binaries (like the RT-built ones) launched from the console detach from this console immediately, therefore leaving the %errorlevel% in this console unaffected.
(0002764)
BrianH
2-Nov-2010 20:16

If there is no way around that then this bug will need to remain until there are official RT console-mode builds for Windows. Which we should have anyway (we can call them /Core).
(0002797)
Carl
4-Nov-2010 23:57

Has a patch been submitted?
(0002800)
abolka
5-Nov-2010 01:00

As currently described, this is not a bug and should be dismissed. The exit code is set correctly.

Here's a simple method to verify this:

> type master.r
REBOL []
print call/wait "r3-a110-3-1 -q slave.r"

> type slave.r
REBOL []
quit/return 42

> r3-a110-3-1 -q master.r
42
(0004669)
abolka
15-Dec-2015 08:21

As mentioned above, this works "properly" for Windows as-is. It's just slightly harder to observe the exit code in GUI-mode builds (see my 2010-11-05 comment). As the open source code-base can be now built either way, the remaining concern from BrianH is addressed as well, so I'll close this.

Date User Field Action Change
15-Dec-2015 08:21 abolka Status Modified waiting => dismissed
15-Dec-2015 08:21 abolka Comment : 0004669 Added -
5-Nov-2010 22:45 BrianH Comment : 0002811 Removed -
5-Nov-2010 22:44 BrianH Comment : 0002811 Added -
5-Nov-2010 01:21 abolka Comment : 0002800 Modified -
5-Nov-2010 01:21 abolka Comment : 0002800 Modified -
5-Nov-2010 01:19 abolka Comment : 0002800 Modified -
5-Nov-2010 01:00 abolka Comment : 0002800 Added -
4-Nov-2010 23:57 carl Comment : 0002797 Added -
4-Nov-2010 23:56 carl Status Modified submitted => waiting
4-Nov-2010 23:55 carl Summary Modified QUIT/return doesn't set the errorlevel on Windows => On WINAPI main exe's: QUIT/return doesn't set the errorlevel
2-Nov-2010 22:33 abolka Comment : 0002765 Removed -
2-Nov-2010 22:31 abolka Comment : 0002765 Added -
2-Nov-2010 20:16 BrianH Comment : 0002764 Added -
2-Nov-2010 19:44 abolka Comment : 0002763 Modified -
2-Nov-2010 19:42 abolka Comment : 0002763 Added -
2-Nov-2010 08:46 BrianH Code Modified -
2-Nov-2010 08:46 BrianH Description Modified -
2-Nov-2010 08:43 BrianH Ticket Added -