summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 08:18:25 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commita0114d0b8be05d62bc1eb0e68642f7c31a766ade (patch)
treed96c79f59b6d852608e889e68a647813da896bdc /src/ninep
parent4a7d377d160cd95c89acad2abaf08bc533ff02a8 (diff)
downloadpardes-a0114d0b8be05d62bc1eb0e68642f7c31a766ade.tar.gz
pardes-a0114d0b8be05d62bc1eb0e68642f7c31a766ade.zip
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 <[email protected]>
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/ctl.zig23
1 files changed, 23 insertions, 0 deletions
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();