Skip to content

_diff: insulate line-reading from caller's $/ - #2

Merged
plicease merged 1 commit into
mainfrom
fix-diff-record-separator
Sep 29, 2026
Merged

plicease merged 1 commit into
mainfrom
fix-diff-record-separator

Conversation

@plicease

Copy link
Copy Markdown
Member

_diff reads the diff subprocess's output line-by-line via <$stdout>, which implicitly relies on the caller not having changed $/. If a caller left $/ set to undef (slurp mode) or another non-default value

  • for example via an improperly scoped local $/; earlier in the same process - reading an already-at-EOF pipe returns an empty string once instead of undef immediately. That phantom empty "line" was treated as a real line of diff output, producing a false failure for two JSON documents that are actually the same.

Found while integrating this module into a large test suite where an unrelated script had left $/ globally altered.

_diff reads the diff subprocess's output line-by-line via <$stdout>,
which implicitly relies on the caller not having changed $/. If a
caller left $/ set to undef (slurp mode) or another non-default value
- for example via an improperly scoped `local $/;` earlier in the same
process - reading an already-at-EOF pipe returns an empty string once
instead of undef immediately. That phantom empty "line" was treated as
a real line of diff output, producing a false failure for two JSON
documents that are actually the same.

Found while integrating this module into a large test suite where an
unrelated script had left $/ globally altered.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@plicease
plicease merged commit da8f2de into main Sep 29, 2026
14 checks passed
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