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.zig12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 68b62186..c2a78fb8 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -388,11 +388,11 @@ fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ?
const b = std.meta.stringToEnum(Builtin, word) orelse {
// A setting this build's frontend cannot show (Lift, GripWidth on a
// terminal) is known, and says so rather than sound misspelt.
- if (config.Runtime.find(word) != null) {
+ if (builtins.absentWhy(word) orelse if (config.Runtime.find(word) != null) @as([]const u8, "GUI-only") else null) |absent| {
var why: [64]u8 = undefined;
// EINVAL, a request this build cannot take, in words 9ns reads
// as that: `invalid`.
- return refuse(p, req, std.fmt.bufPrint(&why, "{s} is GUI-only, invalid here", .{word}) catch "GUI-only, invalid here", line);
+ return refuse(p, req, std.fmt.bufPrint(&why, "{s} is {s}, invalid here", .{ word, absent }) catch "GUI-only, invalid here", line);
}
return refuse(p, req, "unknown control message", line);
};
@@ -1704,6 +1704,14 @@ test "a setting this frontend cannot show says GUI-only, and DumpDir reads back
if (!builtins.capabilities.lift) {
try testing.expectEqualStrings("Lift is GUI-only, invalid here \"Lift on\"", wr(p, root_ctl, "Lift on\n").reply.ename);
try testing.expectEqualStrings("GripWidth is GUI-only, invalid here \"GripWidth 120\"", wr(p, root_ctl, "GripWidth 120\n").reply.ename);
+ // A builtin the GUI alone has, written to a ctl or an exec, never
+ // runs as a shell command.
+ if (comptime !pardes.font_picker) {
+ try testing.expectEqualStrings("Fonts is GUI-only, invalid here \"Fonts\"", wr(p, root_ctl, "Fonts\n").reply.ename);
+ const ran = wr(p, root_exec, "Fonts\n");
+ try testing.expectEqual(E.IO, ran.errno());
+ try testing.expectEqualStrings("Fonts is GUI-only, invalid here", ran.reply.ename);
+ }
}
try testing.expectEqualStrings("unknown control message \"Liftt on\"", wr(p, root_ctl, "Liftt on\n").reply.ename);
var buf: [900]u8 = undefined;