summaryrefslogtreecommitdiffstats
path: root/sysif.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-12-11 07:21:04 -0800
committerKaz Kylheku <kaz@kylheku.com>2023-12-11 07:21:04 -0800
commit17f11d14178db6e8367ba598bc2e4a1f0fae4d59 (patch)
treea6d7ec8ffea761859ade6bdb447fc3ee29cbd4ed /sysif.c
parent2b896e09bdf71fb94e40a105b681c26938daa961 (diff)
downloadtxr-17f11d14178db6e8367ba598bc2e4a1f0fae4d59.tar.gz
txr-17f11d14178db6e8367ba598bc2e4a1f0fae4d59.tar.bz2
txr-17f11d14178db6e8367ba598bc2e4a1f0fae4d59.zip
load: load block value should be exit status.
When TXR executes a top-level program, such that it will exit when the last form in that program terminates, it simulates a load. There is a block named load visible, and the program can evaluate a (return-from load <expr>). The value of that <expr> is thrown away, and the termination status is always unsuccessful. In this patch, (return-from load <expr>) is made to work such that the value of <expr> will determine the exit status, according to the same interpretation that (exit <expr>) would give to the value. * sysif.[ch] (exit_wrap): Static function becomes external. * txr.c (txr_main): In the cases where we execute a file and return from main, we now call exit_wrap instead. The termination status is not simply based on whether the file was successfully read, but takes into account the load block. * tests/019/load-ret/{script.tl,bad.tl}: New files. * tests/019/load-ret/load-ret.tl: New tests. * txr.1: Documented.
Diffstat (limited to 'sysif.c')
-rw-r--r--sysif.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sysif.c b/sysif.c
index b02ec607..6eedb011 100644
--- a/sysif.c
+++ b/sysif.c
@@ -220,7 +220,7 @@ static val daemon_wrap(val nochdir, val noclose)
}
#endif
-static val exit_wrap(val status)
+val exit_wrap(val status)
{
val self = lit("exit");
int stat;