mirror of
https://github.com/Tarrasch/zsh-autoenv.git
synced 2024-11-29 09:50:59 +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:
parent
d2f447e445
commit
364c0fbb2a
@ -195,11 +195,11 @@ _autoenv_source_dir=${0:A:h}
|
|||||||
|
|
||||||
_autoenv_source() {
|
_autoenv_source() {
|
||||||
local env_file=$1
|
local env_file=$1
|
||||||
_autoenv_event=$2
|
autoenv_event=$2
|
||||||
local _autoenv_envfile_dir=${3:-${1:A:h}}
|
local _autoenv_envfile_dir=${3:-${1:A:h}}
|
||||||
|
|
||||||
_autoenv_from_dir=$_autoenv_chpwd_prev_dir
|
autoenv_from_dir=$_autoenv_chpwd_prev_dir
|
||||||
_autoenv_to_dir=$PWD
|
autoenv_to_dir=$PWD
|
||||||
|
|
||||||
# Source varstash library once.
|
# Source varstash library once.
|
||||||
if [[ -z "$functions[(I)autostash]" ]]; then
|
if [[ -z "$functions[(I)autostash]" ]]; then
|
||||||
@ -221,7 +221,7 @@ _autoenv_source() {
|
|||||||
# Unset vars set for enter/leave scripts.
|
# Unset vars set for enter/leave scripts.
|
||||||
# This should not get done for recursion (via autoenv_source_parent),
|
# This should not get done for recursion (via autoenv_source_parent),
|
||||||
# and can be useful to have in general after autoenv was used.
|
# 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() {
|
_autoenv_get_file_upwards() {
|
||||||
|
18
tests/cwd.t
18
tests/cwd.t
@ -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
|
$ source $TESTDIR/setup.sh
|
||||||
|
|
||||||
@ -7,8 +7,8 @@ Setup env actions / output.
|
|||||||
$ AUTOENV_LOOK_UPWARDS=1
|
$ AUTOENV_LOOK_UPWARDS=1
|
||||||
$ mkdir -p sub/sub2
|
$ mkdir -p sub/sub2
|
||||||
$ cd sub
|
$ cd sub
|
||||||
$ echo 'echo ENTERED: PWD:${PWD:t} from:${_autoenv_from_dir:t} to:${_autoenv_to_dir:t}' > .env
|
$ 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}' > .env.leave
|
$ 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.
|
Manually create auth files.
|
||||||
|
|
||||||
@ -17,21 +17,21 @@ Manually create auth files.
|
|||||||
The actual tests.
|
The actual tests.
|
||||||
|
|
||||||
$ cd .
|
$ cd .
|
||||||
ENTERED: PWD:sub from:sub to:sub
|
ENTERED: PWD:sub from:sub to:sub event:enter
|
||||||
|
|
||||||
$ cd ..
|
$ cd ..
|
||||||
LEFT: PWD:sub from:sub to:cwd.t
|
LEFT: PWD:sub from:sub to:cwd.t event:leave
|
||||||
|
|
||||||
$ cd sub/sub2
|
$ 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.
|
Check that symlinked dirs get handled correctly.
|
||||||
|
|
||||||
$ cd ../..
|
$ cd ../..
|
||||||
LEFT: PWD:sub from:sub2 to:cwd.t
|
LEFT: PWD:sub from:sub2 to:cwd.t event:leave
|
||||||
$ ln -s sub sub_linked
|
$ ln -s sub sub_linked
|
||||||
$ cd 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
|
$ cd sub2
|
||||||
ENTERED: PWD:sub from:sub_linked to:sub2
|
ENTERED: PWD:sub from:sub_linked to:sub2 event:enter
|
||||||
$ cd .
|
$ cd .
|
||||||
|
@ -8,8 +8,8 @@ Setup env actions / output.
|
|||||||
|
|
||||||
Create env files in root dir.
|
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 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 LEFT_root: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t}' > .env.leave
|
||||||
$ test_autoenv_auth_env_files
|
$ test_autoenv_auth_env_files
|
||||||
|
|
||||||
Create env files in sub dir.
|
Create env files in sub dir.
|
||||||
@ -18,8 +18,8 @@ Create env files in sub dir.
|
|||||||
$ cd sub
|
$ cd sub
|
||||||
ENTERED_root: PWD:recurse-upwards.t 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 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 LEFT_sub: PWD:${PWD:t} from:${autoenv_from_dir:t} to:${autoenv_to_dir:t}' > .env.leave
|
||||||
$ test_autoenv_auth_env_files
|
$ test_autoenv_auth_env_files
|
||||||
|
|
||||||
The actual tests.
|
The actual tests.
|
||||||
|
Loading…
Reference in New Issue
Block a user