Skip to content

Bash source resolution: extensionless shebang scripts and bare source lib.sh are not resolved #2171

Description

@safishamsi

Follow-up to #2141 / #2157 (which resolves calls into sourced-file functions). Two coverage gaps remain, both verified during review of #2157. Neither is a regression; each is a miss, not a fabrication.

  1. Extensionless shebang scripts. _SHEBANG_DISPATCH routes #!/usr/bin/env bash extensionless files to extract_bash, but the source-resolution filter selects bash results by suffix (p.suffix in (".sh", ".bash")). A sourced extensionless lib gets its functions indexed but calls into it never resolve.

    • Fix direction: select bash results by shape (a node whose metadata.language == "bash") instead of by suffix.
    • Test: extensionless mylib with a bash shebang, sourced by a.sh; assert the calls edge into mylib's function.
  2. Bare source lib.sh (no ./ prefix). Only the raw.startswith((".", "/")) branch records bash_sources; a bare name falls through to the imports fallback and never resolves, even though the file usually sits next to the script.

    • Fix direction: in the else branch, if (path.parent / raw).is_file(), also append a bash_sources entry. Low priority (bash resolves bare names via $PATH at runtime).

Transitive sources (a→b→c, a calls c's function) are intentionally left unresolved (conservative).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions