From 70ea4cb543df4724a977d7e8c10f2b5f470df94f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 14:10:15 -0300 Subject: Kill with a name and nothing running says "Kill: nothing running" and succeeds, as bare Kill does Bare `Kill` with nothing running is a message, not a failure: a script's Kill has nothing left to do. `Kill make` in the same state failed the write with "no running command has that first word", as though make were the mistake. With nothing running at all, named or not, Kill is now the message. It still fails when commands run but none has the word. The two tests that used `Kill zzz` as a builtin that always fails now use `Unmount zzz`. Co-Authored-By: Claude Opus 5.5 --- src/builtins.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/builtins.zig') diff --git a/src/builtins.zig b/src/builtins.zig index 5a2037cf..ba67766d 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -609,11 +609,13 @@ pub const Kill = struct { const names = std.mem.trim(u8, c.arg orelse "", " \t\r\n"); var stopped = false; var jobless = false; + var running = false; for (c.p.panes, 0..) |slot, id| { const pane = slot orelse continue; // A command pane's child is the command: the whole of its // process group goes, as acme's Kill ends the process. if (pane.command) |line| if (!pane.command_done) { + running = true; const said = std.mem.trim(u8, line, " \t"); const first = said[0 .. std.mem.indexOfAny(u8, said, " \t") orelse said.len]; if (names.len > 0) { @@ -627,6 +629,7 @@ pub const Kill = struct { continue; }; if (!panes.terminal.commandRunning(pane)) continue; + running = true; const sent = pane.sent_command.?; if (names.len > 0) { var words = std.mem.tokenizeAny(u8, names, " \t"); @@ -640,9 +643,11 @@ pub const Kill = struct { } if (stopped) return; if (jobless) return c.p.reportFailure(c.id, "Kill: no job to signal (its shell runs it without job control)"); - if (names.len > 0) + // Said, but no failure: a script's Kill, named or not, has nothing + // left to do. Only commands running, none of them the one named, is. + if (names.len > 0 and running) c.p.reportFailure(c.id, "Kill: no running command has that first word") - else // said, but no failure: a script's Kill has nothing left to do + else c.p.setMessage(c.id, "Kill: nothing running"); } }; -- cgit v1.3