Skip to content

fix: add directory short-circuit to -T handler#100

Draft
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-fttext-directory-check
Draft

fix: add directory short-circuit to -T handler#100
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-fttext-directory-check

Conversation

@Koan-Bot
Copy link
Copy Markdown
Contributor

@Koan-Bot Koan-Bot commented Apr 28, 2026

What

Adds directory detection to the -T handler in _check_from_stat, matching the existing -B handler behavior.

Why

The -B handler already short-circuits for directories (PR #91), but -T was missed. In Perl, both -T and -B return true for directories. Without this check, -T on a mocked directory attempts to open the (possibly non-existent) path on disk for heuristic content analysis, which silently fails.

How

  • Added S_IFDIR mode-bit check to the -T dispatch entry, identical to the -B pattern
  • Added explicit @stat guard to the -s handler for consistency with -e, -M, -C, -A (was relying on implicit undef propagation from empty array access)

Testing

  • New t/T-directory-check.t verifying -T and -B directory behavior symmetry, plus -T and -s on non-existent mock files
  • Full test suite passes

🤖 Generated with Claude Code


Quality Report

Changes: 2 files changed, 78 insertions(+), 2 deletions(-)

Code scan: clean

Tests: passed (0 Tests)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

The -B handler already short-circuits for directories (returning true
without opening the file for heuristic content check), but -T did not.
In Perl, both -T and -B return true for directories. Without this
check, -T on a mocked directory would attempt to open the (possibly
non-existent) path on disk for content heuristics, failing silently.

Also adds explicit @stat guard to the -s handler for consistency with
-e, -M, -C, -A handlers (previously relied on implicit undef
propagation from empty array access).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant