diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-05-18 18:23:25 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-05-18 18:23:25 +0300 |
commit | fe3535dbeec8f3f0fca9e6b895c993e59846e103 (patch) | |
tree | 10a20d25edf32adb45739ce6f2cc626b98a7391d /src/core-commands.c | |
parent | 394fe39825cf4fc2f12ad511d8fea2bb61ee4837 (diff) | |
download | sciteco-fe3535dbeec8f3f0fca9e6b895c993e59846e103.tar.gz |
allow process exit status to be determined by macros
* Any value left on the numeric stack now determines the exit code.
This ensures you can call n^C as the SciTECO version of exit(n).
It will also work with n$$ in the top level macro.
But you don't necessarily need any of these commands.
* Could be useful in shell scripting as in
`sciteco -e "@EB/file/ :@S/foo/\"F1'"` to fail `foo` is not found.
Diffstat (limited to 'src/core-commands.c')
-rw-r--r-- | src/core-commands.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core-commands.c b/src/core-commands.c index 141ce0a..337e8df 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -1320,7 +1320,7 @@ teco_state_control_xor(teco_machine_main_t *ctx, GError **error) } /*$ ^C exit - * ^C -- Exit program immediately + * [n]^C -- Exit program immediately * * Lets the top-level macro return immediately * regardless of the current macro invocation frame. @@ -1333,6 +1333,10 @@ teco_state_control_xor(teco_machine_main_t *ctx, GError **error) * effectively just like \(lq-EX\fB$$\fP\(rq * (when executed in the top-level macro at least). * + * Any numeric parameter is returned by the process + * as its exit status. + * By default, the success code is returned. + * * The \fBquit\fP hook is still executed. */ static void @@ -1678,6 +1682,9 @@ teco_state_escape_input(teco_machine_main_t *ctx, gunichar chr, GError **error) * Returning from the top-level macro in batch mode * will exit the program or start up interactive mode depending * on whether program exit has been requested. + * If \fB$$\fP exits the program, any remaining numeric parameter + * is returned by the process as its exit status. + * By default, the success code is returned. * \(lqEX\fB$$\fP\(rq is thus a common idiom to exit * prematurely. * |