From a0114d0b8be05d62bc1eb0e68642f7c31a766ade Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 08:18:25 -0300 Subject: Grep with no hit says grep: no match, and a pane directory that is not there is passed over Grep walks every pane's directory; one not there (a scratch named into a directory not made yet) failed the whole search with `file not found`. Such a root is passed over now, and a search that finds nothing says `grep: no match` and opens no empty +Search. Co-Authored-By: Claude Opus 5.5 --- src/ninep/ctl.zig | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/ninep/ctl.zig') diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 1ef9a2f6..330b9cb7 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1819,6 +1819,29 @@ test "a builtin that needs its argument, written bare to an exec, is EINVAL as t } } +test "Grep with no hit says grep: no match and opens nothing, a missing pane directory passed over" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "a.txt", .data = "alpha\n" }); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)]; + var line: [4200]u8 = undefined; + _ = wr(p, Node.of(serialOf(p), .name), try std.fmt.bufPrint(&line, "{s}/a.txt\n", .{dir})); + // A second pane in a directory that is not there. + const other = try th.newPane(p); + _ = wr(p, Node.of(other, .name), "/tmp/pardes-no-such-dir-zz/b.txt\n"); + var count: usize = 0; + for (p.panes) |slot| count += @intFromBool(slot != null); + const missed = wr(p, Node.of(serialOf(p), .exec), "Grep zzqqnomatchzz\n"); + try testing.expectEqual(E.IO, missed.errno()); + try testing.expectEqualStrings("grep: no match", missed.reply.ename); + var after: usize = 0; + for (p.panes) |slot| after += @intFromBool(slot != null); + try testing.expectEqual(count, after); +} + test "size is monotonic: growing is never refused, and a size once taken is taken again" { const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 60 }); defer p.deinit(); -- cgit v1.3