1
0
mirror of https://github.com/Tarrasch/zsh-autoenv.git synced 2024-11-22 15:30:59 +02:00

Handle missing $1 in _autoenv_hash_pair

This commit is contained in:
Daniel Hahler 2014-12-04 07:11:52 +01:00
parent 4ed8aa2be3
commit 4cdad1d4d5

View File

@ -122,12 +122,18 @@ _autoenv_debug() {
zmodload -F zsh/stat b:zstat zmodload -F zsh/stat b:zstat
# Generate hash pair for a given file ($1).
# A fixed hash value can be given as 2nd arg, but is used with tests only.
_autoenv_hash_pair() { _autoenv_hash_pair() {
local env_file=${1:A} local env_file=${1:A}
local env_shasum local env_shasum
if [[ -n $2 ]]; then if [[ -n $2 ]]; then
env_shasum=$2 env_shasum=$2
else else
if ! [[ -e $env_file ]]; then
echo "Missing file argument for _autoenv_hash_pair!" >&2
return 1
fi
env_shasum=$(shasum $env_file | cut -d' ' -f1) env_shasum=$(shasum $env_file | cut -d' ' -f1)
fi fi
echo "$env_file:$env_shasum:1" echo "$env_file:$env_shasum:1"