summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 12:07:25 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commit996f4d256b95134b0b3d0fc8e8b558792f8f6c61 (patch)
treea6d390dfed6771e64d2264fc77419cd125ecc978
parentd6c877f55669869bc4c360e6d94563ded778d26d (diff)
downloadpardes-996f4d256b95134b0b3d0fc8e8b558792f8f6c61.tar.gz
pardes-996f4d256b95134b0b3d0fc8e8b558792f8f6c61.zip
The ctl word name refuses a leading blank, as the name file does
`name /tmp/x` written to a pane's ctl trimmed the extra blank and named the pane /tmp/x. The same name written to the name file was refused with "a blank at its start", which fs.md gives as the rule, so the name a script wrote is the name it gets. The ctl word now hands the name file everything after its one separating blank. Co-Authored-By: Claude Opus 5.5 <[email protected]>
-rw-r--r--src/ninep/ctl.zig15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index e44368ea..0bbc0319 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -910,8 +910,10 @@ fn acmeCtl(p: *Pardes, req: Req, serial: u32, line: []const u8, apply: bool) Acm
const File = tree.PaneFile;
// A word written to one of the pane's own files, as acme's is to its.
const Into = struct { file: File, data: []const u8 };
+ // `name` takes all after its one blank, as the name file takes what is
+ // written: a blank at its start is refused there, not trimmed here.
const into: ?Into = if (std.mem.eql(u8, word, "name") and rest.len > 0)
- .{ .file = .name, .data = rest }
+ .{ .file = .name, .data = line[word.len + 1 ..] }
else if (std.mem.eql(u8, line, "clean"))
.{ .file = .dirty, .data = "0" }
else if (std.mem.eql(u8, line, "dirty"))
@@ -2443,6 +2445,17 @@ test "a look that misses file:/re/ names the file, and is logged as its pane's"
try testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "err {d} look: {s}/f.txt: no match for regexp", .{ f_serial, dir })));
}
+test "the ctl word name refuses a leading blank, as the name file does" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ const serial = serialOf(p);
+ const r = wr(p, Node.of(serial, .ctl), "name /tmp/lead.txt\n");
+ try testing.expectEqual(E.INVAL, r.errno());
+ try testing.expectEqualStrings("bad character in file name: a blank at its start", r.reply.ename);
+ try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "name /tmp/ok.txt\n").reply.status);
+ try testing.expectEqualStrings("/tmp/ok.txt", pane_files.nameOf(p, p.panes[0].?));
+}
+
test "a builtin that takes no argument, written with one to an exec, is refused wrong #args, as at a ctl" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();