Skip to content

Bash extractor: a run of "$(dirname "$0")/x.sh", a script in the script's own folder, gets no edge #5575

Backlog

Description

@yashsaxena

What happens

A script that runs another script in its own folder with "$(dirname "$0")/x.sh", by its path or through bash, gets no edge to it:

"$(dirname "$0")/helper.sh" --flag
bash "$(dirname "$0")/job.sh" build

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

Reproduction

Three files in a new git repo:

# bin/tool
#!/usr/bin/env bash
"$(dirname "$0")/helper.sh" --flag
bash "$(dirname "$0")/job.sh" build
# bin/helper.sh
#!/usr/bin/env bash
echo "helper $*"
# bin/job.sh
#!/usr/bin/env bash
echo "job $*"

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

calls bin/tool (script) -> bin/helper.sh (script)
calls bin/tool (script) -> bin/job.sh (script)

Got

No edges.

Cause and fix

The run branch of walk() reads a literal path, or strips leading ${VAR}/ parts; a $(dirname "$0")/ prefix is neither, so both runs are dropped.
$(dirname "$0"), $(dirname "${BASH_SOURCE[0]}") and their brace forms name the script's own folder, so the path after them resolves next to the script, as a literal ./x.sh does.
A path with .. is left alone.
Related, not duplicates: #3416 (exec-position paths from a variable) and #5566 (runs of "$VAR/x" and scripts with no extension).
We carry this fix as a local patch and will 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