Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resolving of relative script paths #62

Draft
wants to merge 2 commits into
base: bash-5.2
Choose a base branch
from

Conversation

jansorg
Copy link
Collaborator

@jansorg jansorg commented Dec 31, 2024

At first, the script's working directory is used to resolve a relative path. Then, the script's parent directory is used. This commit removes duplicated code shared between file.sh and filecache.sh.

  • I've switched the lookup order, _Dbg_dir=('\$cdir' '\$cwd' ) to _Dbg_dir=('\$cwd' '\$cdir' ), because IMHO the current working directory should be looked at first. At runtime, that's what the debuggee does (I suppose)
  • I've changed typeset _Dbg_cdir="${_Dbg_source_file%/*}" to typeset _Dbg_cdir="${_Dbg_init_cwd%/*}" because that seems more suitable to reference the script's location. In dbg-main.sh variable _Dbg_source_file is used in a loop (without a break) and does not seem to refer to the debuggee script passed to bashdb. Because of the missing break, I think it's always set to $DBG_RESTART_FILE when the loop is done.

Supersedes #61

Update: This is breaking other cases, discussed in #63

At first, the script's working directory is used to resolve a relative path. Then, the script's parent directory is used.
This commit removes duplicated code shared between file.sh and filecache.sh.
@jansorg jansorg marked this pull request as draft December 31, 2024 12:13
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.

1 participant