Skip to content

Commit

Permalink
Disable extglob during wd's execution (#111)
Browse files Browse the repository at this point in the history
There are additional problems with variable expansion related to ~, e.g. in prompts and terminal titles
  • Loading branch information
tomterl authored Oct 10, 2022
1 parent 1617b5b commit 13e2f87
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions wd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ wd_path()
wd_show()
{
local name_arg=$1
setopt | grep -q extendedglob
local extglob=$?
# if there's an argument we look up the value
if [[ -n $name_arg ]]
then
Expand All @@ -292,7 +290,6 @@ wd_show()
wd_print_msg "$WD_GREEN" "Warp point: ${WD_GREEN}$name_arg${WD_NOC} -> $points[$name_arg]"
fi
else
[[ $extglob ]] && setopt noextendedglob
# hax to create a local empty array
local wd_matches
wd_matches=()
Expand All @@ -312,7 +309,6 @@ wd_show()
else
wd_print_msg "$WD_YELLOW" "No warp point to $(echo "$PWD" | sed "s:$HOME:~:")"
fi
[[ $extglob ]] && setopt extendedglob
fi
}

Expand Down Expand Up @@ -397,6 +393,11 @@ else
wd_export_static_named_directories
fi

# disable extendedglob for the complete wd execution time
setopt | grep -q extendedglob
wd_extglob_is_set=$?
[[ $wd_extglob_is_set ]] && setopt noextendedglob

# load warp points
typeset -A points
while read -r line
Expand Down Expand Up @@ -483,6 +484,9 @@ fi
# if not, next time warp will pick up variables from this run
# remember, there's no sub shell

[[ $wd_extglob_is_set ]] && setopt extendedglob

unset wd_extglob_is_set
unset wd_warp
unset wd_add
unset wd_remove
Expand Down

0 comments on commit 13e2f87

Please sign in to comment.