autoenv.zsh | 4 +++- tests/ZDOTDIR.options/.zshenv | 1 + tests/_autoenv_utils.t | 4 ++++ tests/setup.zsh | 1 + tests/source-parent-until.t | 16 ++++++++++++++++ diff --git a/autoenv.zsh b/autoenv.zsh index a7aaeb40de9e656ec954d80f2064b71a557b3d8a..e70eec165000b6a6fdfc99a0191caeaaa84ce73c 100644 --- a/autoenv.zsh +++ b/autoenv.zsh @@ -364,12 +364,13 @@ if [[ $abs_parent_dir == $look_until ]]; then break fi - last=$parent_dir + last=$abs_parent_dir parent_dir="${parent_dir}/.." done } autoenv-edit() { + emulate -L zsh local env_file local -a files local -A check @@ -402,6 +403,7 @@ eval $editor "$files" } _autoenv_chpwd_handler() { + emulate -L zsh _autoenv_debug "Calling chpwd handler: PWD=$PWD" if (( $AUTOENV_DISABLED )); then diff --git a/tests/ZDOTDIR.options/.zshenv b/tests/ZDOTDIR.options/.zshenv index 61c751bd7225d14b0625c00950d477708dd46ab3..cacdc9b17734b31996a10c09b1a121fdec4eecf9 100644 --- a/tests/ZDOTDIR.options/.zshenv +++ b/tests/ZDOTDIR.options/.zshenv @@ -1,2 +1,3 @@ # Set uncommon options that caused problems in the past. setopt noclobber +setopt shwordsplit diff --git a/tests/_autoenv_utils.t b/tests/_autoenv_utils.t index cd8b9ad5f9cda835540c197b4385133cdb8e0ab0..86e93c92eb50911232967492c54fe62d92a7203f 100644 --- a/tests/_autoenv_utils.t +++ b/tests/_autoenv_utils.t @@ -96,3 +96,7 @@ $ mkdir dir $ touch -t 201401010102 dir $ _autoenv_get_file_mtime dir 1388538120 + +Stops when last (absolute) path does not change anymore. + + $ _autoenv_get_file_upwards / doesnotexist nevermatches diff --git a/tests/setup.zsh b/tests/setup.zsh index 0bbdbafa74ad8d9b7572b6b6bbae141d1512cef0..02f41b3790129b13cfd974fa7a19fbd06c06851a 100644 --- a/tests/setup.zsh +++ b/tests/setup.zsh @@ -28,6 +28,7 @@ fi # Add file ($1), version ($2), and optional hash ($3) to authentication file. test_autoenv_add_to_env() { + emulate -L zsh [[ -d ${AUTOENV_AUTH_FILE:h} ]] || mkdir -p ${AUTOENV_AUTH_FILE:h} _autoenv_deauthorize $1 { diff --git a/tests/source-parent-until.t b/tests/source-parent-until.t index c02a312adb063748d34bde8aa5c8f25c6468006f..a6700bbc5f1a2f09842edc83edf997d78b687394 100644 --- a/tests/source-parent-until.t +++ b/tests/source-parent-until.t @@ -90,3 +90,19 @@ $ cd sub2/sub3 autoenv_source_parent_from_sub3: ENTERED_sub: PWD:sub3 from:sub to:sub3 done_sub3 + +Handles dirs with spaces. + + $ mkdir "dir with space" + $ echo "echo entered \$PWD\n" >| "dir with space/.autoenv.zsh" + $ test_autoenv_add_to_env "dir with space/.autoenv.zsh" + $ cd "dir with space" + entered */dir with space (glob) + +Handles dirs with spaces outside any root (should not hang). + + $ cd $CRAMTMP || exit + LEFT_root: * (glob) + LEFT_sub: * (glob) + $ mkdir "dir with space" + $ cd "dir with space"