Skip to content

Fix find_binary_in_dir to prefer true binaries over same-named non-binary files#46

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-symbolic-link-fastfetch
Draft

Fix find_binary_in_dir to prefer true binaries over same-named non-binary files#46
Copilot wants to merge 3 commits intomainfrom
copilot/fix-symbolic-link-fastfetch

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 13, 2026

Which issue does this PR resolve?

Closes #

Description of this PR

Packages like fastfetch ship archives containing both a binary (usr/bin/fastfetch) and a bash-completion script (usr/share/bash-completion/completions/fastfetch). find_binary_in_dir returned whichever the directory walker hit first, which could be the completion file.

Fix: Instead of returning the first name-match, prefer candidates that are likely real binaries:

  • bin/ ancestor check — file lives under a directory named bin
  • Executable bit check (Unix) — file has +x permission
  • Fallback — first name-match, preserving existing behavior for simple packages
// Before: returns first match (could be a completion script)
for entry in walker.filter_map(Result::ok) {
    if path.is_file() && fname == bin_name {
        return Some(path);
    }
}

// After: prefers likely binaries, falls back to first match
if is_likely_binary(path) {
    return Some(path);
}
if fallback.is_none() {
    fallback = Some(path);
}

Copilot AI linked an issue Apr 13, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 13, 2026 17:33
…tion scripts

When packages like fastfetch contain both a binary (usr/bin/fastfetch) and
a bash-completion script (usr/share/bash-completion/completions/fastfetch),
the old code returned whichever file the directory walker found first.

The new implementation collects all name-matches and prefers candidates
that either live under a `bin/` directory or (on Unix) have the executable
permission bit set, falling back to the first match otherwise.

Agent-Logs-Url: https://github.com/Yangmoooo/inro/sessions/25b7f4a4-f13a-445b-b1b1-5f0e02912adb

Co-authored-by: Yangmoooo <72434870+Yangmoooo@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix auto-select true binary for fastfetch Fix find_binary_in_dir to prefer true binaries over same-named non-binary files Apr 13, 2026
Copilot AI requested a review from Yangmoooo April 13, 2026 17:37
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.

Failed to auto-select true binary

2 participants