summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 03:19:28 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commit85452cbb28ec78913d72017fdcb666c40e2fc153 (patch)
treeaa85236bc8e86cf6c17c35d7f32abe942682ccc6 /src/host
parenta3085da09e222238071c4948f6893b21542ac695 (diff)
downloadsketchbook-85452cbb28ec78913d72017fdcb666c40e2fc153.tar.gz
sketchbook-85452cbb28ec78913d72017fdcb666c40e2fc153.zip
fs: a read answered with the sketch closed says so on stderr
With no instance running, fs serves the tree from the save's newest State or the declared defaults; a read then looked exactly like the running sketch's, and a script that read while the sketch was still starting took the save for it (drat-meout's scripts met this). The words the refused files already give ("<name> is not running: this is its save's newest State, frame N of ...") go to stderr before a read's answer; help, ls and complete stay quiet. test-fs checks it; the README says so. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/host')
-rw-r--r--src/host/root.zig6
1 files changed, 6 insertions, 0 deletions
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);
}