Skip to content

Bash extractor: $(fn) in an argument or a test gets no call edge (only x=$(fn) does, #2978) #5561

Backlog

Description

@yashsaxena

What happens

A function called inside $( ) gets a calls edge only when the substitution is a whole assignment value (x=$(fn), fixed in #2978).
Anywhere else a $(fn) is just as much a call, but Graphify drops it: in a command's argument (echo "at $(stamp)") and in a test ([ "$(stamp)" != "" ]).
Value-returning helpers used this way look dead.

Reproduced on graphifyy 0.9.122 (newest on PyPI), installed with pip, nothing patched, Python 3.12, Ubuntu.

Reproduction

Two files in a new git repo:

# bin/tool
#!/usr/bin/env bash
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
. "$ROOT/lib/stamp.sh"
main() {
  echo "built at $(stamp)"
  [ "$(stamp)" != "" ] && echo ok
}
main
# lib/stamp.sh
stamp() { date +%s; }

Command:

graphify extract "$PWD" --code-only --out /tmp/out
jq -r '.links[] | select(.relation != "contains" and .relation != "defines")
       | "\(.relation) \(.source) -> \(.target)"' /tmp/out/graphify-out/graph.json

Expected

imports_from bin/tool -> lib/stamp.sh
calls bin/tool main -> lib/stamp.sh stamp

Got

calls bin/tool (script) -> bin/tool main
imports_from bin/tool -> lib/stamp.sh

Cause and fix

The call walk skips a command inside an expansion unless the expansion is an assignment's value.
The rule that fits bash: a $(fn) anywhere but in a statement's command-name position is a call.
This extends #2978 (assignment values) and narrows #2141 (calls into a sourced file) to the case still missing.

We carry this fix as a local patch and can open a PR.

Activity

  1. github-actions commented on Nov 28, 2026

    @github-actions

    Thanks for opening this issue, @yashsaxena. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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