Skip to content

fix: readlink failure returns undef for correct list context#253

Merged
atoomic merged 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/fix-readlink-return-undef
Feb 28, 2026
Merged

fix: readlink failure returns undef for correct list context#253
atoomic merged 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/fix-readlink-return-undef

Conversation

@Koan-Bot
Copy link
Contributor

What

__readlink failure paths now use return undef; instead of bare return;.

Why

CORE::readlink returns undef on failure. Bare return; produces an empty list () in list context instead of (undef), which breaks callers that do my @ret = readlink(...) — they get 0 elements instead of 1 undefined element.

Same pattern as the __open fix in PR #244.

How

Changed 3 bare return; statements to return undef; in __readlink:

  • undef path (after carp warning)
  • non-existent mock
  • non-symlink file (EINVAL)

Testing

Added 2 tests in t/readlink.t verifying list-context returns (undef) for both non-link and non-existent cases.

🤖 Generated with Claude Code

CORE::readlink returns undef on failure. Our __readlink override used
bare `return;` which returns an empty list in list context instead of
(undef). This caused `my @ret = readlink($non_link)` to return ()
instead of (undef), breaking list-context callers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@atoomic atoomic marked this pull request as ready for review February 28, 2026 03:02
@atoomic atoomic merged commit 268cb7d into cpanel:master Feb 28, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants