Skip to content

Commit 3a7206b

Browse files
author
Ryan Nielsen
committed
Handle spaces in paths when generating caches
Fixes zsh-users#582 Current antigen branch doesn't properly handle spaces in paths when generating caches, so if your antigen plugins live in a path with spaces, the resulting $ADOTDIR/init.zsh will have improper paths for fpath and path. We'll address this by moving away from arrays when generating the _PATH and _fpath variables for cached output, and will instead append strings wrapped in double quotes. Then, when actually creating the caches, we'll again avoid zsh array parameter expansion and instead just insert the string list. This approach sidesteps a number of subtle issues that arise when relying on arrays, and results is a very straightforward cache file.
1 parent c91f77c commit 3a7206b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

bin/antigen.zsh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,8 +1818,8 @@ typeset -g _ZCACHE_CAPTURE_PREFIX
18181818
fi
18191819
_sources+=("source '${record}';"$'\n')
18201820
elif [[ -d $record ]]; then
1821-
_PATH+=("${record}")
1822-
_fpath+=("${record}")
1821+
_PATH+="\"${record}\""
1822+
_fpath+="\"${record}\""
18231823
fi
18241824
done
18251825

@@ -1834,7 +1834,7 @@ antigen () {
18341834
return 0;
18351835
}
18361836
typeset -gaU fpath path
1837-
fpath+=(${_fpath[@]}) path+=(${_PATH[@]})
1837+
fpath+=(${_fpath}) path+=(${_PATH})
18381838
_antigen_compinit () {
18391839
autoload -Uz compinit; compinit $ANTIGEN_COMPINIT_OPTS -d "$ANTIGEN_COMPDUMP"; compdef _antigen antigen
18401840
add-zsh-hook -D precmd _antigen_compinit

src/ext/cache.zsh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ typeset -g _ZCACHE_CAPTURE_PREFIX
3434
fi
3535
_sources+=("source '${record}';"$'\n')
3636
elif [[ -d $record ]]; then
37-
_PATH+=("${record}")
38-
_fpath+=("${record}")
37+
_PATH+="\"${record}\""
38+
_fpath+="\"${record}\""
3939
fi
4040
done
4141

@@ -50,7 +50,7 @@ antigen () {
5050
return 0;
5151
}
5252
typeset -gaU fpath path
53-
fpath+=(${_fpath[@]}) path+=(${_PATH[@]})
53+
fpath+=(${_fpath}) path+=(${_PATH})
5454
_antigen_compinit () {
5555
autoload -Uz compinit; compinit $ANTIGEN_COMPINIT_OPTS -d "$ANTIGEN_COMPDUMP"; compdef _antigen antigen
5656
add-zsh-hook -D precmd _antigen_compinit

0 commit comments

Comments
 (0)