This uses `emulate -L zsh` (as a more broad approach to `setopt
localtoptions noshwordsplit`, or quoting things) in the entry points to
zsh-autoenv.
Fixes https://github.com/Tarrasch/zsh-autoenv/issues/75
This prevents issues where autoenv scripts use $0. When a shell enters the directory holding the autoenv scripts, it works as expected with $0 being the path to the symlink. However, if the shell enters one of its child directories the path to the script is dereferenced, and $0 is instead the path to the symlink's target.
From `man 1 zshexpn`:
> A – Turn a file name into an absolute path as the 'a' modifier does, and then pass the result through the realpath(3) library function to resolve symbolic links.
Note: Symlinks are dereferenced elsewhere for authorization, so that behavior is unchanged.
A new parameter is added to `_autoenv_hash_pair` to specify the version, defaulting to the latest (2). It outputs a `cksum`-based hash for version 2 and `shasum`-based for version 1.
Moves logic to check for an entry in `$AUTOENV_AUTH_FILE` into its own function (`_autoenv_authorized_pair`), as it may need to be called twice.
Modifies `_autoenv_authorized_env_file` to check for v1 entries when v2 fails.
Fixes#53. Alternative implementation to #54.
I have noticed that `autostash` called an (accidentally)
defined/overwritten `stash` function.
While it's not possible to put this into a local scope, this will at
least make it less polluting by default (when autostashing is not used).
Additionally we could source it always (not just once), but then it
would only re-overwrite the function.
A better fix would be to prefix the functions explicitly, e.g.
`autoenv_autostash` etc.
Closes https://github.com/Tarrasch/zsh-autoenv/pull/42.
The variables are local now, which makes them being handled correctly
when calling `autoenv_source_parent`.
Without this, a call to `autoenv_source_parent` overwrites the values in
the current scope.
This changes the defaults:
- AUTOENV_FILE_ENTER: .env => .autoenv.zsh
- AUTOENV_FILE_LEAVE: .env_leave => .autoenv_leave.zsh
`.env` is usually used only for key-value pairs for environment
settings, e.g. with foreman. We do not want to interfere with this.
This also renames the setting/variable AUTOENV_ENV_FILENAME to
AUTOENV_AUTH_FILE, and uses the [XDG
spec](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables)
for the default location.
The new default location for the auth file will be
~/.local/share/autoenv_auth.
When the old setting is used, or the previous default exists, a warning
is given with instructions.
Fixes https://github.com/Tarrasch/zsh-autoenv/issues/31.
Closes https://github.com/Tarrasch/zsh-autoenv/pull/32.
This is not really necessary, except for the convenience of being in the
.env file's directory during the hook.
But it messes around with the "cd history", e.g. `cd -`!
To reference the .env file or its directory, `$autoenv_env_file` and
`${autoenv_env_file:h}` can be used instead.