diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2021-10-23 18:01:40 -0600 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2021-10-23 18:01:40 -0600 |
commit | fad92c603be0ff36825cc53bf8c485d4b95c7869 (patch) | |
tree | 407fe826be62a3543b6feab4f3552f58575234de /plugins/z/z.sh | |
parent | c674485e6b4abe313469900997d893d2940ee843 (diff) | |
parent | f1dd97bb2a9df55fae9b1ca26c829b9f8b290667 (diff) | |
download | zsh-fad92c603be0ff36825cc53bf8c485d4b95c7869.tar.gz zsh-fad92c603be0ff36825cc53bf8c485d4b95c7869.tar.bz2 zsh-fad92c603be0ff36825cc53bf8c485d4b95c7869.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'plugins/z/z.sh')
-rw-r--r-- | plugins/z/z.sh | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/plugins/z/z.sh b/plugins/z/z.sh index 13008a60e..67f504e27 100644 --- a/plugins/z/z.sh +++ b/plugins/z/z.sh @@ -42,6 +42,8 @@ _z() { [ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return _z_dirs () { + [ -f "$datafile" ] || return + local line while read line; do # only count directories @@ -54,14 +56,16 @@ _z() { if [ "$1" = "--add" ]; then shift - # $HOME isn't worth matching - [ "$*" = "$HOME" ] && return + # $HOME and / aren't worth matching + [ "$*" = "$HOME" -o "$*" = '/' ] && return # don't track excluded directory trees - local exclude - for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do - case "$*" in "$exclude*") return;; esac - done + if [ ${#_Z_EXCLUDE_DIRS[@]} -gt 0 ]; then + local exclude + for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do + case "$*" in "$exclude"*) return;; esac + done + fi # maintain the data file local tempfile="$datafile.$RANDOM" |