1
0
mirror of https://github.com/Tarrasch/zsh-autoenv.git synced 2024-12-22 10:50:16 +02:00

Remove underscore prefix from vars provided for .env files

Fixes https://github.com/Tarrasch/zsh-autoenv/issues/11
This commit is contained in:
Daniel Hahler 2014-12-02 18:49:23 +01:00
parent d2f447e445
commit 364c0fbb2a
3 changed files with 17 additions and 17 deletions

View File

@ -195,11 +195,11 @@ _autoenv_source_dir=${0:A:h}
_autoenv_source() {
local env_file=$1
_autoenv_event=$2
autoenv_event=$2
local _autoenv_envfile_dir=${3:-${1:A:h}}
_autoenv_from_dir=$_autoenv_chpwd_prev_dir
_autoenv_to_dir=$PWD
autoenv_from_dir=$_autoenv_chpwd_prev_dir
autoenv_to_dir=$PWD
# Source varstash library once.
if [[ -z "$functions[(I)autostash]" ]]; then
@ -221,7 +221,7 @@ _autoenv_source() {
# Unset vars set for enter/leave scripts.
# This should not get done for recursion (via autoenv_source_parent),
# and can be useful to have in general after autoenv was used.
# unset _autoenv_event _autoenv_from_dir _autoenv_to_dir
# unset autoenv_event autoenv_from_dir autoenv_to_dir
}
_autoenv_get_file_upwards() {

View File

@ -1,4 +1,4 @@
Test $PWD, $_autoenv_from_dir and _autoenv_to_dir.
Test $PWD, $autoenv_event, $autoenv_from_dir and $autoenv_to_dir.
$ source $TESTDIR/setup.sh
@ -7,8 +7,8 @@ Setup env actions / output.
$ AUTOENV_LOOK_UPWARDS=1
$ mkdir -p sub/sub2
$ cd sub
$ echo 'echo ENTERED: PWD:${PWD:t} from:${_autoenv_from_dir:t} to:${_autoenv_to_dir:t}' > .env
$ echo 'echo LEFT: PWD:${PWD:t} from:${_autoenv_from_dir:t} to:${_autoenv_to_dir:t}' > .env.leave
$ echo 'echo ENTERED: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t} event:${autoenv_event}' > .env
$ echo 'echo LEFT: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t} event:${autoenv_event}' > .env.leave
Manually create auth files.
@ -17,21 +17,21 @@ Manually create auth files.
The actual tests.
$ cd .
ENTERED: PWD:sub from:sub to:sub
ENTERED: PWD:sub from:sub to:sub event:enter
$ cd ..
LEFT: PWD:sub from:sub to:cwd.t
LEFT: PWD:sub from:sub to:cwd.t event:leave
$ cd sub/sub2
ENTERED: PWD:sub from:cwd.t to:sub2
ENTERED: PWD:sub from:cwd.t to:sub2 event:enter
Check that symlinked dirs get handled correctly.
$ cd ../..
LEFT: PWD:sub from:sub2 to:cwd.t
LEFT: PWD:sub from:sub2 to:cwd.t event:leave
$ ln -s sub sub_linked
$ cd sub_linked
ENTERED: PWD:sub from:cwd.t to:sub_linked
ENTERED: PWD:sub from:cwd.t to:sub_linked event:enter
$ cd sub2
ENTERED: PWD:sub from:sub_linked to:sub2
ENTERED: PWD:sub from:sub_linked to:sub2 event:enter
$ cd .

View File

@ -8,8 +8,8 @@ Setup env actions / output.
Create env files in root dir.
$ echo 'echo ENTERED_root: PWD:${PWD:t} from:${_autoenv_from_dir:t} to:${_autoenv_to_dir:t}' > .env
$ echo 'echo LEFT_root: PWD:${PWD:t} from:${_autoenv_from_dir:t} to:${_autoenv_to_dir:t}' > .env.leave
$ echo 'echo ENTERED_root: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t}' > .env
$ echo 'echo LEFT_root: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t}' > .env.leave
$ test_autoenv_auth_env_files
Create env files in sub dir.
@ -18,8 +18,8 @@ Create env files in sub dir.
$ cd 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
$ 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
$ test_autoenv_auth_env_files
The actual tests.