1
0
mirror of https://github.com/Tarrasch/zsh-autoenv.git synced 2025-12-14 02:15:11 +02:00

Automatically upgrade v1 hashes (SHA-1) to v2 (cksum) (#55)

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.
This commit is contained in:
Rob Speed
2017-01-10 06:07:39 -05:00
committed by Daniel Hahler
parent 398b6f4f54
commit dfb5648505
4 changed files with 97 additions and 26 deletions

View File

@@ -28,9 +28,9 @@ if [[ -f $AUTOENV_AUTH_FILE ]]; then
echo -n >| $AUTOENV_AUTH_FILE
fi
# Add file $1 (with optional hash $2) to authentication file.
# Add file ($1), version ($2), and optional hash ($3) to authentication file.
test_autoenv_add_to_env() {
_autoenv_hash_pair $1 ${2:-} >>| $AUTOENV_AUTH_FILE
_autoenv_hash_pair $1 1 ${2:-} >>| $AUTOENV_AUTH_FILE
}
# Add enter and leave env files to authentication file.