summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--build.zig2
-rw-r--r--src/host/root.zig6
3 files changed, 11 insertions, 2 deletions
diff --git a/README.md b/README.md
index 9dbd183..733cc3d 100644
--- a/README.md
+++ b/README.md
@@ -1421,7 +1421,10 @@ on that tree, the server's refusals printed in its words, exit status 1.
With the sketch closed, `fs` serves the same tree itself, with no
window, from the save's newest State (the default save, or `--state`'s),
else from State's declared defaults: `README`, `commands` and `state/`
-answer, and the rest say the sketch is not running.
+answer, and the rest say the sketch is not running. A `read` answered
+that way says so on stderr (`drat-meout is not running: this is its
+save's newest State, frame 61 of ...`), so a script that reads before the
+sketch is up does not take the save for it.
```
ctl write a verb a line: ctl's own (screenshot, profile-reset),
diff --git a/build.zig b/build.zig
index e41482b..41502b1 100644
--- a/build.zig
+++ b/build.zig
@@ -575,7 +575,7 @@ pub fn build(b: *Build) void {
\\fs help ctl | grep -q '^ click X Y '
\\fs write ctl quit; wait $pid
\\test ! -e "$rt"/9p/sketchbook/fstest
- \\test "$(fs read state/dots/buffer/2/kind)" = .small
+ \\test "$(fs read state/dots/buffer/2/kind 2>err)" = .small; grep -q 'replay is not running' err
\\! fs read status 2>err; grep -q 'replay is not running' err
\\rm -rf "$d"/*
});
diff --git a/src/host/root.zig b/src/host/root.zig
index 1edd9a4..f15493b 100644
--- a/src/host/root.zig
+++ b/src/host/root.zig
@@ -202,6 +202,12 @@ fn fs(init: std.process.Init, linked: ?abi.Sketch, options: Host.Options, words:
defer thread.join();
try f.init(io, .{ .socket = .{ .handle = fds[1], .address = undefined } }, user);
defer f.close();
+ // A read answered here is not the running sketch's: said on stderr, so
+ // a script that reads before the sketch is up does not take it for one.
+ if (words.len > 0 and std.mem.eql(u8, words[0], "read")) {
+ try err.interface.print("{s}\n", .{from});
+ try err.interface.flush();
+ }
return c9.verbs.run(&f, words, &in.interface, &out.interface, &err.interface);
}