Fix breakpoint hit in file sourced with relative path after script changed the working directory#61
Fix breakpoint hit in file sourced with relative path after script changed the working directory#61
Conversation
…rking directory The current working directory of the debugged script must always be used as fallback, as it's the directory used by the script to locate files with a relative path.
|
Looks good to me. For me, I'd probably add a comment or rather clarification as to why path searching is done outside of the case when the name starts with "." The way I think of it is that there are explicit relative path names, those that start with "." (or "..") and implicit relative path names which do not start with either "." or "/". Testing for an absolute name was done above, so that leaves relative (both implicit and explicit). So the comment around the "elif" is misleading because that branch is about just one of the kinds of relative paths. As for the duplicate code, yes, those two should be combined. I think the situation was more or less a result of parallel evolution. The intent of |
|
Thanks! I'll try to clean up the code tomorrow. I think that we should test against the script's current working directory first, because that what it's (probably?) using itself. But I'll have to think a bit more about the possible edge-cases... I'll also try to get rid of the duplicate code. |
I think you are correct. |
|
Closing, as it doesn't seem to be the right fix. I'll create a new issue |
The script (shown below) of my integration tests of BashSupport Pro failed to hit a breakpoint in the function definition of
include3.sh.The breakpoint was not hit because the lookup in
hook.shwas not using the current working directory of the script to find a path by relative path. In this case../dir3/include3.shwas not looked inside the PWD$DIR/dir2but only elsewhere.This PR changes the file lookup to always use the configured lookup directories
_Dbg_diras fallback if the lookup of absolute and relative paths did not yield a valid result.Also, the result of the lookup based on
_Dbg_dirwas not checked against$_Dbg_filenameslike the lookup a few lines above.Tests are passing and the breakpoint is now hit. But I'm not sure how to add a test case for this.
Question:
This code looks suspiciously similar to the code I changed. Should I change this, even though I'm not sure how it's used?
bashdb/lib/file.sh
Lines 104 to 118 in b78910a
Script of my test case