mirror of
https://github.com/Tarrasch/zsh-autoenv.git
synced 2024-11-25 16:31:00 +02:00
Fix handling of stack for leave, add to stack for autoenv_source_parent
This commit is contained in:
parent
175a4eb628
commit
869e679b79
@ -29,6 +29,9 @@ autoenv_source_parent() {
|
|||||||
&& _autoenv_check_authorized_env_file $parent_env_file; then
|
&& _autoenv_check_authorized_env_file $parent_env_file; then
|
||||||
|
|
||||||
local parent_env_dir=${parent_env_file:A:h}
|
local parent_env_dir=${parent_env_file:A:h}
|
||||||
|
|
||||||
|
_autoenv_stack_entered_add $parent_env_file
|
||||||
|
|
||||||
_autoenv_source $parent_env_file enter $parent_env_dir
|
_autoenv_source $parent_env_file enter $parent_env_dir
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -44,7 +47,7 @@ _autoenv_stack_entered_add() {
|
|||||||
local env_file=$1
|
local env_file=$1
|
||||||
|
|
||||||
# Remove any existing entry.
|
# Remove any existing entry.
|
||||||
_autoenv_stack_entered[$_autoenv_stack_entered[(i)$1]]=()
|
_autoenv_stack_entered_remove $env_file
|
||||||
|
|
||||||
# Append it to the stack, and remember its mtime.
|
# Append it to the stack, and remember its mtime.
|
||||||
_autoenv_stack_entered+=($env_file)
|
_autoenv_stack_entered+=($env_file)
|
||||||
@ -62,7 +65,7 @@ _autoenv_get_file_mtime() {
|
|||||||
# Remove an entry from the stack.
|
# Remove an entry from the stack.
|
||||||
_autoenv_stack_entered_remove() {
|
_autoenv_stack_entered_remove() {
|
||||||
local env_file=$1
|
local env_file=$1
|
||||||
_autoenv_stack_entered=(${_autoenv_stack_entered#$env_file})
|
_autoenv_stack_entered[$_autoenv_stack_entered[(i)$env_file]]=()
|
||||||
_autoenv_stack_entered_mtime[$env_file]=
|
_autoenv_stack_entered_mtime[$env_file]=
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +221,7 @@ _autoenv_chpwd_handler() {
|
|||||||
if _autoenv_check_authorized_env_file $env_file_leave; then
|
if _autoenv_check_authorized_env_file $env_file_leave; then
|
||||||
_autoenv_source $env_file_leave leave $prev_dir
|
_autoenv_source $env_file_leave leave $prev_dir
|
||||||
fi
|
fi
|
||||||
_autoenv_stack_entered_remove $prev_dir
|
_autoenv_stack_entered_remove $prev_file
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -50,3 +50,9 @@ Test lookup of containing elements.
|
|||||||
$ _autoenv_stack_entered_contains not-added
|
$ _autoenv_stack_entered_contains not-added
|
||||||
[1]
|
[1]
|
||||||
|
|
||||||
|
Test removing.
|
||||||
|
|
||||||
|
$ _autoenv_stack_entered_remove sub
|
||||||
|
$ echo ${_autoenv_stack_entered}
|
||||||
|
sub/sub2 non-existing sub/file
|
||||||
|
|
||||||
|
@ -98,10 +98,11 @@ Add sub/sub2/.env file.
|
|||||||
done_sub2
|
done_sub2
|
||||||
|
|
||||||
Go to root.
|
Go to root.
|
||||||
|
This should not trigger the enter event, because it was handled via
|
||||||
|
autoenv_source_parent already.
|
||||||
|
|
||||||
$ cd ../..
|
$ cd ../..
|
||||||
LEFT_sub: PWD:sub from:sub2 to:recurse-upwards.t
|
LEFT_sub: PWD:sub from:sub2 to:recurse-upwards.t
|
||||||
ENTERED_root: PWD:recurse-upwards.t from:sub2 to:recurse-upwards.t
|
|
||||||
|
|
||||||
|
|
||||||
Changing the root .env should trigger re-authentication via autoenv_source_parent.
|
Changing the root .env should trigger re-authentication via autoenv_source_parent.
|
||||||
|
Loading…
Reference in New Issue
Block a user