summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig53
1 files changed, 31 insertions, 22 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 89549933..4749fc94 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -515,9 +515,15 @@ fn blanked(line: []const u8, buf: []u8) []const u8 {
/// as on a tag; acme's lowercase verbs are the pane ctl's and alias none.
fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ?Reply {
var sp = std.mem.indexOfAny(u8, line, " \t");
- // `Word+arg` for a word that takes one so (`Tty+bash`), as exec does.
- if (sp == null) if (std.mem.indexOfScalar(u8, line, '+')) |at| if (std.meta.stringToEnum(Builtin, line[0..at])) |head| {
- if (builtins.registry.plusArg(head)) sp = at;
+ // `Word+arg` for a word that takes one so (`Term+bash`), as exec does;
+ // an old name's too (`Tty+bash`).
+ if (sp == null) if (std.mem.indexOfScalar(u8, line, '+')) |at| {
+ const head = for (pardes.exec.acme_words) |w| {
+ if (std.mem.eql(u8, line[0..at], w.acme)) break w.pardes orelse "";
+ } else line[0..at];
+ if (std.meta.stringToEnum(Builtin, head)) |b| if (builtins.registry.plusArg(b)) {
+ sp = at;
+ };
};
const typed = line[0 .. sp orelse line.len];
// acme's words: checked as the pardes word they run as, or refused.
@@ -592,7 +598,7 @@ pub fn runBuiltin(p: *Pardes, req: Req, id: usize, line: []const u8) ?Reply {
p.fs.failure_len = 0;
defer p.fs.no_prompt = false;
// What a ctl write touched reads back from /look and /exec as a click's
- // does (`run`), so a script that made a pane with `Tty` finds it there.
+ // does (`run`), so a script that made a pane with `Term` finds it there.
const context = if (p.panes[id]) |pane| pane.serial else 0;
const before = Serials.snapshot(p);
_ = exec_line.executeBuiltinLine(p, id, line);
@@ -1768,7 +1774,7 @@ test "DumpConfig's whole report writes back to the root ctl, line by line, with
} else return error.NoDumpConfigPane;
defer testing.allocator.free(report);
// What this shell cannot show is a comment, never a value it refuses.
- if (pardes.platform == .tty) try testing.expect(std.mem.indexOf(u8, report, "# GripWidth unsupported\n") != null);
+ if (pardes.platform == .tui) try testing.expect(std.mem.indexOf(u8, report, "# GripWidth unsupported\n") != null);
var lines = std.mem.splitScalar(u8, report, '\n');
while (lines.next()) |line| {
if (line.len == 0) continue;
@@ -1967,7 +1973,7 @@ test "Mount dials its peer and fails, mounting nothing, when none answers; a loo
try testing.expect(th.logHas(p, "look: /n/gone/f.txt: dial failed: no answer"));
}
-test "Tty in a directory that is not there fails and makes no pane; a shell that never started answers a run" {
+test "Term in a directory that is not there fails and makes no pane; a shell that never started answers a run" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
const serial = serialOf(p);
@@ -1981,15 +1987,15 @@ test "Tty in a directory that is not there fails and makes no pane; a shell that
defer p.host = .{};
var count: usize = 0;
for (p.panes) |slot| count += @intFromBool(slot != null);
- const refused = wr(p, Node.of(serial, .ctl), "Tty\n");
+ const refused = wr(p, Node.of(serial, .ctl), "Term\n");
try testing.expectEqual(E.NOENT, refused.errno());
- try testing.expectStringStartsWith(refused.reply.ename, "Tty: /tmp/pardes-no-such-dir-zz: no such directory");
+ try testing.expectStringStartsWith(refused.reply.ename, "Term: /tmp/pardes-no-such-dir-zz: no such directory");
var after: usize = 0;
for (p.panes) |slot| after += @intFromBool(slot != null);
try testing.expectEqual(count, after);
// A terminal whose shell the host could not start.
_ = wr(p, Node.of(serial, .name), "/tmp/f.txt\n");
- try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "Tty\n").reply.status);
+ try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "Term\n").reply.status);
const term = p.active;
p.shellFailed(@intCast(term), error.FileNotFound);
const run_node = Node.of(p.panes[term].?.serial, .pty_run);
@@ -2066,7 +2072,7 @@ 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);
+ try testing.expectEqual(Status.ok, wr(p, Node.of(serialOf(p), .ctl), "Term\n").reply.status);
p.update(.tick); // announced
const term = p.active;
// The host says where its shell started: where it was already named.
@@ -2161,7 +2167,7 @@ test "pty/ctl exec in a directory that is gone fails ENOENT; a shell that cannot
try testing.expectEqualStrings("shell: permission denied", p.fs.late_failure[0..p.fs.late_failure_len]);
}
-test "a script whose interpreter is not there: Tty refuses it up front, only an err logged, and pty/ctl exec keeps the running shell" {
+test "a script whose interpreter is not there: Term refuses it up front, only an err logged, and pty/ctl exec keeps the running shell" {
const p = try th.withTerm(testing.allocator);
defer p.deinit();
const Starting = struct {
@@ -2178,14 +2184,14 @@ test "a script whose interpreter is not there: Tty refuses it up front, only an
const serial = serialOf(p);
var count: usize = 0;
for (p.panes) |slot| count += @intFromBool(slot != null);
- const refused = wr(p, Node.of(serial, .ctl), try std.fmt.bufPrint(&line, "Tty {s}/bad\n", .{dir}));
+ const refused = wr(p, Node.of(serial, .ctl), try std.fmt.bufPrint(&line, "Term {s}/bad\n", .{dir}));
try testing.expectEqual(E.NOENT, refused.errno());
- try testing.expectEqualStrings("Tty: interpreter /no/such/interp not found", refused.reply.ename);
+ try testing.expectEqualStrings("Term: interpreter /no/such/interp not found", refused.reply.ename);
var after: usize = 0;
for (p.panes) |slot| after += @intFromBool(slot != null);
try testing.expectEqual(count, after);
// The log gained the err and nothing else: no new, msg or del.
- try testing.expect(th.logHas(p, "Tty: interpreter /no/such/interp not found\n"));
+ try testing.expect(th.logHas(p, "Term: interpreter /no/such/interp not found\n"));
try testing.expect(!th.logHas(p, "\nmsg "));
try testing.expect(!th.logHas(p, "\ndel "));
// The shell to start again is that script: refused before the running
@@ -2407,7 +2413,7 @@ test "a focus moved over 9P tells the programs that asked for focus reports, as
const first = for (p.panes) |slot| {
if (slot) |pane| if (pane.isTerminal()) break pane.serial;
} else return error.NoShell;
- try testing.expectEqual(Status.ok, wr(p, Node.of(first, .exec), "Tty\n").reply.status);
+ try testing.expectEqual(Status.ok, wr(p, Node.of(first, .exec), "Term\n").reply.status);
var shells: [2]usize = undefined;
var n: usize = 0;
for (p.panes, 0..) |slot, id| if (slot) |pane| if (pane.isTerminal() and n < 2) {
@@ -2536,11 +2542,11 @@ test "size is monotonic: growing is never refused, and a size once taken is take
p.unattended = true;
const root_ctl = @backingInt(tree.TopFile.ctl);
const new = @backingInt(tree.TopFile.new);
- // The dogfood's repro: Newcol, three pane/new, a Tty, then pane/new
+ // The dogfood's repro: Newcol, three pane/new, a Term, then pane/new
// until a column has no room (ENOSPC).
try testing.expectEqual(Status.ok, wr(p, root_ctl, "Newcol\n").reply.status);
for (0..3) |_| try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .open, .node = new }).reply.status);
- try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[p.active].?.serial, .ctl), "Tty\n").reply.status);
+ try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[p.active].?.serial, .ctl), "Term\n").reply.status);
p.sync();
while (call(p, .{ .tag = 1, .op = .open, .node = new }).reply.status == .ok) p.sync();
p.sync();
@@ -2875,12 +2881,15 @@ test "a body write to an image pane says its body takes none, not that terminals
try testing.expectEqualStrings(pane_files.e_no_body, wr(p, Node.of(doc.serial, .body), "x").reply.ename);
}
-test "Tty+bash on a pane ctl is Tty with its argument, as exec and the tag take it" {
+test "Term+bash on a pane ctl is Term with its argument, as exec and the tag take it" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
- const r = call(p, .{ .tag = 1, .op = .write, .node = Node.of(serialOf(p), .ctl), .data = "Tty+sh\n" });
- try testing.expectEqual(Status.ok, r.reply.status);
- try testing.expect(r.spawned);
+ // Tty+sh too: Term's old name, as a saved tag holds it.
+ for ([_][]const u8{ "Term+sh\n", "Tty+sh\n" }) |data| {
+ const r = call(p, .{ .tag = 1, .op = .write, .node = Node.of(serialOf(p), .ctl), .data = data });
+ try testing.expectEqual(Status.ok, r.reply.status);
+ try testing.expect(r.spawned);
+ }
}
test "a Rename that reaches other files previews them, says so, and is the pane a waiting write answers" {
@@ -3003,7 +3012,7 @@ test "a command or a terminal refused for room is refused before anything is log
defer p.deinit();
const exec = Node.of(serialOf(p), .exec);
var buf: [32]u8 = undefined;
- for ([_][]const u8{ "ls\n", "Tty\n" }) |line| {
+ for ([_][]const u8{ "ls\n", "Term\n" }) |line| {
// Each a pane of its own until the column has no room for one more.
var before = p.next_serial;
var tries: usize = 0;