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 breakpoint hit in file sourced with relative path after script changed the working directory #61

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ typeset -a _Dbg_dir
_Dbg_dir=('\$cdir' '\$cwd' )

# _Dbg_cdir is the directory in which the script is located.
[[ -z ${_Dbg_cdir} ]] && typeset _Dbg_cdir=${_Dbg_source_file%/*}
[[ -z ${_Dbg_cdir} ]] && typeset _Dbg_cdir=$(pwd)
[[ -z ${_Dbg_cdir} ]] && typeset _Dbg_cdir="${_Dbg_source_file%/*}"
[[ -z ${_Dbg_cdir} ]] && typeset _Dbg_cdir="$(pwd)"

# Either fill out or strip filename as determined by "basename_only"
# and annotate settings
Expand Down
39 changes: 20 additions & 19 deletions lib/filecache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,37 +139,38 @@ function _Dbg_is_file {

if [[ ${find_file:0:1} == '/' ]] ; then
# Absolute file name
try_find_file=$(_Dbg_expand_filename "$find_file")
try_find_file="$(_Dbg_expand_filename "$find_file")"
if [[ -n ${_Dbg_filenames[$try_find_file]} ]] ; then
echo "$try_find_file"
return 0
fi
elif [[ ${find_file:0:1} == '.' ]] ; then
# Relative file name
try_find_file=$(_Dbg_expand_filename "${_Dbg_init_cwd}/$find_file")
try_find_file="$(_Dbg_expand_filename "${_Dbg_init_cwd}/$find_file")"
# FIXME: turn into common subroutine
if [[ -n ${_Dbg_filenames[$try_find_file]} ]] ; then
echo "$try_find_file"
return 0
fi
else
# Resolve file using _Dbg_dir
typeset -i n=${#_Dbg_dir[@]}
typeset -i i
for (( i=0 ; i < n; i++ )) ; do
typeset basename="${_Dbg_dir[i]}"
if [[ $basename == '\$cdir' ]] ; then
basename=$_Dbg_cdir
elif [[ $basename == '\$cwd' ]] ; then
basename=$(pwd)
fi
try_find_file="$basename/$find_file"
if [[ -f "$try_find_file" ]] ; then
echo "$try_find_file"
return 0
fi
done
fi

# Resolve file using _Dbg_dir
typeset -i n=${#_Dbg_dir[@]}
typeset -i i
for (( i=0 ; i < n; i++ )) ; do
typeset basename="${_Dbg_dir[i]}"
if [[ $basename == '\$cdir' ]] ; then
basename=$_Dbg_cdir
elif [[ $basename == '\$cwd' ]] ; then
basename=$(pwd)
fi
try_find_file="$(_Dbg_expand_filename "$basename/$find_file")"
if [[ -n ${_Dbg_filenames[$try_find_file]} ]] ; then
echo "$try_find_file"
return 0
fi
done

echo ''
return 1
}
Expand Down
Loading