summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/fs.md12
-rw-r--r--src/ninep/ctl.zig16
-rw-r--r--src/pardes.zig4
3 files changed, 27 insertions, 5 deletions
diff --git a/docs/fs.md b/docs/fs.md
index 4b0214c3..b4c006d3 100644
--- a/docs/fs.md
+++ b/docs/fs.md
@@ -732,11 +732,13 @@ an open renders its frame; stat the entry.
`/log` is one ring (64 KiB) that records whether or not anyone reads it:
`new`, `del`, `rename` (a terminal's too, as its shell changes directory --
-a new terminal is `new N /` until its shell says where it is, then renamed;
-it runs `ls` once at its first prompt, a greeting that shows the directory
-it opened in, since a terminal is named by its directory and nothing else
-on it says where it is --
-since a terminal is named by its directory), `exit <serial> <N>` before
+a new terminal is `new N <dir>`, named by the directory it is started in,
+and renamed only when its shell goes elsewhere (the boot's, started with
+no directory given, is `new N /` until its shell says where it is); it
+runs `ls` once, at its shell's first prompt only, never later over what
+someone ran or typed first, a greeting that shows the directory it opened
+in, since a terminal is named by its directory and nothing else on it says
+where it is), `exit <serial> <N>` before
the `del` of a terminal whose shell exited by itself, `ask <serial> <what>
<choices>` when a pane asks a question (answered by `answer` on its ctl;
`ask <serial> save path` when a Save made over 9P, on a terminal or a
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 0ec5dc2a..30091ae1 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -1856,6 +1856,22 @@ test "Unmount of a name not mounted says no such mount, which a mount reads as E
try testing.expectStringStartsWith(refused.reply.ename, "Unmount: no such mount nothere");
}
+test "a terminal told the directory it already goes by logs no rename" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ _ = wr(p, Node.of(serialOf(p), .name), "/tmp/f.txt\n");
+ try testing.expectEqual(Status.ok, wr(p, Node.of(serialOf(p), .ctl), "Tty\n").reply.status);
+ p.update(.tick); // announced
+ const term = p.active;
+ // The host says where its shell started: where it was already named.
+ p.setCwd(term, "/tmp");
+ var rec: [32]u8 = undefined;
+ try testing.expect(!th.logHas(p, try std.fmt.bufPrint(&rec, "rename {d} ", .{p.panes[term].?.serial})));
+ // Somewhere else is a rename.
+ p.setCwd(term, "/usr");
+ try testing.expect(th.logHas(p, try std.fmt.bufPrint(&rec, "rename {d} /usr", .{p.panes[term].?.serial})));
+}
+
test "size is monotonic: growing is never refused, and a size once taken is taken again" {
const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 60 });
defer p.deinit();
diff --git a/src/pardes.zig b/src/pardes.zig
index de4d6abc..c6e68517 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -4813,6 +4813,10 @@ pub const Pardes = struct {
std.debug.assert(p.panes[id] == null);
if (cwd.len > limits.host_path_cap) return error.PathTooLong;
const pane = try panes.Terminal.create(p.gpa, p.screen_w, p.screen_h);
+ // Named by the directory it is started in from the first, so the
+ // shell saying it is there is no rename (`new N /` then `rename`);
+ // out of memory for it, the shell names it when it says.
+ if (cwd.len > 0) pane.setOwnedCwd(cwd) catch {};
panes.Terminal.armShellSpawn(pane);
p.installPane(id, pane);
p.emitSpawn(id, pane.serial, cwd);