summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 11:20:48 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit2c98513a23d060093d690dbd7743dda5ad86c117 (patch)
tree659caed05062b262cf81fbbe701f6ef690a03f55
parent53fcf030b175fc035e62d1d471c01c2e0caefc9e (diff)
downloadpardes-2c98513a23d060093d690dbd7743dda5ad86c117.tar.gz
pardes-2c98513a23d060093d690dbd7743dda5ad86c117.zip
A look at a ./ or ../ name that is not there names the file, not the pane's directory
Any relative name that opened nothing was blamed on the pane's directory (look: .../work/many: no such directory) though it exists; the directory is named only when it is gone. A plain name is still looked for as text, its miss logged as any look's. Co-Authored-By: Claude Opus 5.5 <[email protected]>
-rw-r--r--docs/fs.md4
-rw-r--r--src/look.zig10
-rw-r--r--src/ninep/ctl.zig20
3 files changed, 30 insertions, 4 deletions
diff --git a/docs/fs.md b/docs/fs.md
index 6fa612f5..544a9f84 100644
--- a/docs/fs.md
+++ b/docs/fs.md
@@ -742,7 +742,9 @@ errno that fits, EINVAL for malformed input (an unknown word, a control
character, a command line over 1024 bytes, a `size` or `winsize` out of
range, a bad address or event record), else EIO or the errno the words
name (ENOENT for a pane, file or directory gone -- `look .` from a pane
-whose directory is gone says `look: <dir>: no such directory` -- and for a
+whose directory is gone says `look: <dir>: no such directory`, and a
+`./zz.txt` or `../x` that is not there `look: ./zz.txt: no such file`, while a
+plain `zz.txt` is looked for as text, a miss logged as any look's -- and for a
Find or Grep that finds nothing, `grep: no match, not found`; Grep walks
every pane's directory on this host, passing over panes of the served
tree (`/virtual/`, a peer's `/n/<name>/`) and directories not there,
diff --git a/src/look.zig b/src/look.zig
index f45fe583..236f0687 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -1470,12 +1470,16 @@ pub fn lookAt(p: *Pardes, id: usize, operand: []const u8) void {
}
switch (found) {
.none => {
- // `.` or `..` from a pane whose directory is gone: said, ENOENT,
- // not searched for as a word.
+ // A `./` or `../` name opened nothing: said, ENOENT, not searched
+ // for as a word. What is missing is the pane's directory when
+ // that is gone, else the file named.
if (filesystem.dotRelative(trimmed)) {
const dir = Pardes.paneDir(pane);
var said: [4200]u8 = undefined;
- return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: no such directory", .{dir[0..@min(dir.len, 4096)]}) catch "look: no such directory");
+ const gone = if (comptime pardes.hosted) if (filesystem.localPath(dir)) |local| !exec.isDirectory(local) else false else true;
+ if (gone) return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: no such directory", .{dir[0..@min(dir.len, 4096)]}) catch "look: no such directory");
+ var cut: [miss_path_cap + "…".len]u8 = undefined;
+ return p.reportFailure(id, std.fmt.bufPrint(&said, "look: {s}: no such file", .{missText(trimmed, &cut)}) catch "look: no such file");
}
// A raw terminal's clicks are its program's; a look written over
// 9P is no keyboard input, and searches whatever the key mode.
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index a78a9fcd..4b37c23e 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2036,6 +2036,26 @@ test "/index shows a name as the log does: a newline in it is \\n, controls spac
try testing.expect(std.mem.indexOf(u8, rd(p, @intFromEnum(tree.TopFile.index), 0, 4096).bytes, "/tmp/back\\\\nslash") != null);
}
+test "a look at a ./ or ../ name that is not there names the file, ENOENT; a plain one is looked for as text" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ var tmp = testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.createDirPath(testing.io, "many");
+ 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}/many/a.txt\n", .{dir}));
+ for ([_][]const u8{ "./zz.txt", "../zz.txt" }) |name| {
+ const r = wr(p, Node.of(serialOf(p), .look), try std.fmt.bufPrint(&line, "{s}\n", .{name}));
+ try testing.expectEqual(E.NOENT, r.errno());
+ var want: [64]u8 = undefined;
+ try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "look: {s}: no such file", .{name}), r.reply.ename);
+ }
+ try testing.expectEqual(Status.ok, wr(p, Node.of(serialOf(p), .look), "zz.txt\n").reply.status);
+ try testing.expect(th.logHas(p, "look: no match for \"zz.txt\""));
+}
+
test "a served-tree pane spoils no Grep, and Look . from a gone directory is ENOENT, not /virtual/" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();