]> Sergey Matveev's repositories - zsh-autoenv.git/commitdiff
Handle missing $1 in _autoenv_hash_pair
authorDaniel Hahler <git@thequod.de>
Thu, 4 Dec 2014 06:11:52 +0000 (07:11 +0100)
committerDaniel Hahler <git@thequod.de>
Thu, 4 Dec 2014 06:20:20 +0000 (07:20 +0100)
autoenv.zsh

index 23866f31824a6383af7d8c5814bbbaad00075958..c710389be506ace2ca25ec2971953715b3d3c7ca 100644 (file)
@@ -122,12 +122,18 @@ _autoenv_debug() {
 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() {
   local env_file=${1:A}
   local env_shasum
   if [[ -n $2 ]]; then
     env_shasum=$2
   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)
   fi
   echo "$env_file:$env_shasum:1"