Skip to content

fix(grep): grep -r on single file returns empty#1080

Merged
chaliy merged 2 commits intomainfrom
claude/process-issue-1074-n9fLF
Apr 6, 2026
Merged

fix(grep): grep -r on single file returns empty#1080
chaliy merged 2 commits intomainfrom
claude/process-issue-1074-n9fLF

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 6, 2026

Summary

  • Root cause: OverlayFs::read_dir() returned Ok(vec![]) for file paths instead of Err("not a directory"), so grep -r's fallback file-read branch never triggered
  • Fix: Added explicit file-type check in OverlayFs::read_dir() — if the path resolves to a non-directory in either layer, return an error (per spec requirement in specs/003-vfs.md line 459)
  • Tests: 3 regression tests added:
    • test_grep_recursive_single_file — grep -r on single file with InMemoryFs
    • test_grep_recursive_single_file_overlay — grep -r on single file with OverlayFs (actual bug path)
    • test_read_dir_on_file_returns_error — direct OverlayFs::read_dir correctness test

Test plan

  • cargo test -p bashkit — all 2022 tests pass
  • cargo fmt --check clean
  • cargo clippy --all-targets -- -D warnings clean
  • Rebased on latest main

Closes #1074

chaliy added 2 commits April 6, 2026 00:17
OverlayFs::read_dir() returned Ok(vec![]) for file paths instead of
Err, causing grep -r's fallback file-read path to never trigger.
Added explicit file-type check in OverlayFs::read_dir().

Closes #1074
Directly tests that read_dir returns Err for file paths, per spec
requirement (specs/003-vfs.md line 459).
@chaliy chaliy force-pushed the claude/process-issue-1074-n9fLF branch from bbc9fcd to ad4aa52 Compare April 6, 2026 00:22
@chaliy chaliy merged commit 8243d71 into main Apr 6, 2026
27 checks passed
@chaliy chaliy deleted the claude/process-issue-1074-n9fLF branch April 6, 2026 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

grep -r on a single file returns empty instead of matching

1 participant