7418814677a1b64d584d84be03fbfe38c7760e61

Author
Ryan Zegray <ryan.zegray@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(z): update z to latest version (#10267)

Diff

 1diff --git a/plugins/z/z.sh b/plugins/z/z.sh
 2index 13008a60ebe8c00d0e7f92ec6f153244ffc94905..67f504e27f34cc706340a4995dbbbfbb4fcd9d36 100644
 3--- a/plugins/z/z.sh
 4+++ b/plugins/z/z.sh
 5@@ -42,6 +42,8 @@ _z() {
 6     [ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
 7 
 8     _z_dirs () {
 9+        [ -f "$datafile" ] || return
10+
11         local line
12         while read line; do
13             # only count directories
14@@ -54,14 +56,16 @@ _z() {
15     if [ "$1" = "--add" ]; then
16         shift
17 
18-        # $HOME isn't worth matching
19-        [ "$*" = "$HOME" ] && return
20+        # $HOME and / aren't worth matching
21+        [ "$*" = "$HOME" -o "$*" = '/' ] && return
22 
23         # don't track excluded directory trees
24-        local exclude
25-        for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do
26-            case "$*" in "$exclude*") return;; esac
27-        done
28+        if [ ${#_Z_EXCLUDE_DIRS[@]} -gt 0 ]; then
29+            local exclude
30+            for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do
31+                case "$*" in "$exclude"*) return;; esac
32+            done
33+        fi
34 
35         # maintain the data file
36         local tempfile="$datafile.$RANDOM"