Repository navigation
fix(bash): a run of "$(dirname "$0")/x.sh" is x.sh in the script's own folder (#5575) - #5578
yashsaxena wants to merge 1 commit into
Conversation
…n folder (Graphify-Labs#5575) By its path or through a shell runner; $(dirname "${BASH_SOURCE[0]}") too. A path with .. in it is left out. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the pull request, @yashsaxena. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify review 
1 possible issue to check · High impact
The Bash extractor now recognizes script invocations whose path starts with $(dirname "$0") or a BASH_SOURCE variant, and resolves them relative to the script directory.
1 possible issue we couldn't confirm
- A runner call with a leading flag, such as
bash -e "$(dirname "$0")/x.sh", does not link to the sibling script ·graphify/extractors/bash.py:562
They don't change the score.
Code graph · 623 functions depend on this change
- 1 function became more coupled.
extract_bash()(54 callers). - 2 of 652 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed 6102049
|
Shipped in v0.9.123 (authorship-preserving cherry-pick). Reworked onto #5597's new |
What does this PR do?
Fixes #5575.
A script that runs another script in its own folder as
"$(dirname "$0")/x.sh", by its path or throughbash, got no edge to it.$(dirname "$0"),$(dirname "${BASH_SOURCE[0]}")and their brace forms name the script's own folder, so the path after them now resolves next to the script, the way a literal./x.shdoes.A path with
..in it is left out.Type of change
Verification & Invariants
Invariant: the new path only ever resolves below the script's own folder, and it then goes through the existing
_resolve_safeandis_file()gates, as every run target does.The path accepts only
[A-Za-z0-9._-]segments and rejects..."$(dirname "$0")/x.sh", a script in the script's own folder, gets no edge #5575, on graphifyy 0.9.122 from PyPI).test_extract_bash_script_invocation_in_own_folder_via_dirname(by path, throughbash, and theBASH_SOURCEform), andtest_extract_bash_dirname_invocation_with_dotdot_not_followedguards the..case..shtargets, as before; scripts with no extension are Bash extractor:bash "$ROOT/lib/x.sh"and"$ROOT/bin/tool"(ROOT the script-dir idiom with..; extensionless bash target) get no edge #5566.How was this tested?
I could not run the suite on my machine, so this repo's own CI workflow ran on the branch in my fork:
Graphify-specific checklist