summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 14:10:15 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commit70ea4cb543df4724a977d7e8c10f2b5f470df94f (patch)
tree6cd3d9399a9d954ca629d0c2d212b0a90d3ecd9f /src/builtins.zig
parent3cfc0d921184b5bf25e7855e22003b1ec230c32d (diff)
downloadpardes-70ea4cb543df4724a977d7e8c10f2b5f470df94f.tar.gz
pardes-70ea4cb543df4724a977d7e8c10f2b5f470df94f.zip
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 <[email protected]>
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig9
1 files changed, 7 insertions, 2 deletions
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");
}
};