mirror of
https://github.com/Tarrasch/zsh-autoenv.git
synced 2024-11-26 08:50:59 +02:00
Only source varstash lib if it's being used
I have noticed that `autostash` called an (accidentally) defined/overwritten `stash` function. While it's not possible to put this into a local scope, this will at least make it less polluting by default (when autostashing is not used). Additionally we could source it always (not just once), but then it would only re-overwrite the function. A better fix would be to prefix the functions explicitly, e.g. `autoenv_autostash` etc.
This commit is contained in:
parent
f021750e89
commit
1dd8e8bd46
@ -260,8 +260,12 @@ _autoenv_source() {
|
||||
local autoenv_to_dir=$PWD
|
||||
|
||||
# Source varstash library once.
|
||||
# XXX: pollutes environment with e.g. `stash`, and `autostash` will cause
|
||||
# an overwritten `stash` function to be called!
|
||||
if [[ -z "$functions[(I)autostash]" ]]; then
|
||||
if \grep -qE '\b(autostash|autounstash|stash)\b' $autoenv_env_file; then
|
||||
source ${${funcsourcetrace[1]%:*}:h}/lib/varstash
|
||||
fi
|
||||
# NOTE: Varstash uses $PWD as default for varstash_dir, we might set it to
|
||||
# ${autoenv_env_file:h}.
|
||||
fi
|
||||
@ -331,7 +335,9 @@ _autoenv_chpwd_handler() {
|
||||
fi
|
||||
|
||||
# Unstash any autostashed stuff.
|
||||
if [[ -n "$functions[(I)autostash]" ]]; then
|
||||
varstash_dir=$prev_dir autounstash
|
||||
fi
|
||||
|
||||
_autoenv_stack_entered_remove $prev_file
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user