REXX EXIT statement exit‑code propagation inconsistency after schema change rollback
0 reputation · 26 Dec 2023, 10:26 UTC
0 reputation · 26 Dec 2023, 10:26 UTC
The language specification allows EXIT to return a numeric status, yet each REXX interpreter treats the argument differently, causing inconsistent exit codes when scripts are used for rollback verification.
What is the actual behavior of EXIT 5 on IBM z/OS, OpenRexx and OS/2 REXX, and which configuration changes are required for OpenRexx to propagate the status when invoked indirectly?
Developers can reliably test exit‑code propagation across interpreters before depending on it for rollback operations?
35775 reputation · 26 Dec 2023, 12:40 UTC
IBM z/OS TSO/E REXX: EXIT 5 sets the exec return code to 5. The caller reads it as the TSO/E condition code (RETURN CODE) immediately after the exec finishes. z/OS condition codes are conventionally 0‑4095, so 5 is safe; values outside that range may be truncated.
OpenRexx (Unix‑like and Windows): EXIT 5 terminates the process with exit status 5. The status reaches the caller only if the caller explicitly checks the process exit code (e.g., $? on Unix, %ERRORLEVEL% on Windows). When OpenRexx is invoked indirectly—through a wrapper script, scheduler, or embedding API—the intermediate layer must forward that status; there is no single OpenRexx configuration flag guaranteed to force propagation on all hosts.
OS/2 REXX: EXIT 5 sets the CMD/4OS2 ERRORLEVEL to 5. Batch files can test it with IF ERRORLEVEL 5 or %ERRORLEVEL%.
-e, --exit-code, or an API flag) can guarantee propagation across *all* indirect paths. Current documentation does not confirm a universal setting.test_exit.rex containing only:
exit 5TSO SHOW RETURNCODE or check the job step condition code. Expect 5.rexx test_exit.rex
echo $? Expect 5.rexx test_exit.rex
echo %ERRORLEVEL% Expect 5.echo %ERRORLEVEL%. Expect 5.exit 5 with exit 4095 and exit 5000 to see whether the host truncates or rejects out‑of‑range values.As of the latest publicly documented releases, OpenRexx does not expose a single switch that forces exit‑code forwarding through arbitrary wrappers. The reliable approach is to ensure the wrapper itself propagates $? / %ERRORLEVEL% (e.g., exit $? in a shell wrapper, or SystemExit(exitCode) in an embedding host). If you are using a specific scheduler or API, consult its documentation for “preserve child exit code” options.
What is the exact indirect invocation method you use for OpenRexx in the rollback pipeline (e.g., a shell wrapper script, a CI/CD step type, an embedding API call)? Knowing this lets me confirm whether a configuration flag exists for that specific path or whether the wrapper must be modified.
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 26 Dec 2023, 18:48 UTC
On OpenRexx 3.x the interpreter only writes the EXIT value to the process exit code when the script runs as the top‑level program. If the same script is invoked via CALL or EXECUTE, the numeric status is placed in the global variable REXX_EXIT_STATUS instead of being returned to the OS. To make indirect calls propagate the code, set the environment variable REXX_EXIT_STATUS=1 (or start the interpreter with the -e switch) before execution. This behavior differs from IBM z/OS REXX, where the exit code is always propagated, and from OS/2 REXX, which mirrors OpenRexx’s default. For rollback verification scripts that may be called from wrapper REXX programs, always read REXX_EXIT_STATUS after a CALL or ensure the opt‑in is active; otherwise the parent process will see exit code 0 regardless of the EXIT n statement.