mirror of
https://github.com/Tarrasch/zsh-autoenv.git
synced 2025-01-03 15:00:14 +02:00
Fix $PWD while sourcing .env file - should be dir of .env file
This commit is contained in:
parent
04e44f8244
commit
13c0dbcd2f
@ -157,7 +157,7 @@ _autoenv_source_dir=${0:A:h}
|
||||
_autoenv_source() {
|
||||
local env_file=$1
|
||||
_autoenv_event=$2
|
||||
local _autoenv_envfile_dir=$3
|
||||
local _autoenv_envfile_dir=${3:-${1:A:h}}
|
||||
|
||||
_autoenv_from_dir=$_autoenv_chpwd_prev_dir
|
||||
_autoenv_to_dir=$PWD
|
||||
@ -249,7 +249,7 @@ _autoenv_chpwd_handler() {
|
||||
_autoenv_stack_entered_add $env_file
|
||||
|
||||
# Source the enter env file.
|
||||
_autoenv_source $env_file enter $PWD
|
||||
_autoenv_source $env_file enter
|
||||
|
||||
_autoenv_chpwd_prev_dir=$PWD
|
||||
}
|
||||
|
@ -23,4 +23,4 @@ The actual tests.
|
||||
LEFT: PWD:sub from:sub to:cwd.t
|
||||
|
||||
$ cd sub/sub2
|
||||
ENTERED: PWD:sub2 from:cwd.t to:sub2
|
||||
ENTERED: PWD:sub from:cwd.t to:sub2
|
||||
|
@ -16,7 +16,7 @@ Create env files in sub dir.
|
||||
|
||||
$ mkdir -p sub/sub2
|
||||
$ cd sub
|
||||
ENTERED_root: PWD:sub from:recurse-upwards.t to:sub
|
||||
ENTERED_root: PWD:recurse-upwards.t from:recurse-upwards.t to:sub
|
||||
|
||||
$ echo 'echo ENTERED_sub: PWD:${PWD:t} from:${_autoenv_from_dir:t} to:${_autoenv_to_dir:t}' > .env
|
||||
$ echo 'echo LEFT_sub: PWD:${PWD:t} from:${_autoenv_from_dir:t} to:${_autoenv_to_dir:t}' > .env.leave
|
||||
@ -31,7 +31,7 @@ The actual tests.
|
||||
LEFT_sub: PWD:sub from:sub to:recurse-upwards.t
|
||||
|
||||
$ cd sub/sub2
|
||||
ENTERED_sub: PWD:sub2 from:recurse-upwards.t to:sub2
|
||||
ENTERED_sub: PWD:sub from:recurse-upwards.t to:sub2
|
||||
|
||||
$ cd ..
|
||||
|
||||
@ -150,3 +150,16 @@ Touching the .env file will now source the parent env file.
|
||||
ENTERED_sub: PWD:sub from:sub to:sub
|
||||
ENTER2
|
||||
done_sub
|
||||
|
||||
|
||||
$ cd ..
|
||||
LEFT_sub: PWD:sub from:sub to:recurse-upwards.t
|
||||
$ mkdir sub/sub2/sub3
|
||||
$ cd sub/sub2/sub3
|
||||
autoenv_source_parent_from_sub2:
|
||||
autoenv_source_parent_from_sub:
|
||||
NEW
|
||||
ENTERED_sub: PWD:sub from:recurse-upwards.t to:sub
|
||||
ENTER2
|
||||
done_sub
|
||||
done_sub2
|
||||
|
Loading…
Reference in New Issue
Block a user