summaryrefslogtreecommitdiff
path: root/oh-my-zsh.sh
diff options
context:
space:
mode:
authorMarc Cornellà <hello@mcornella.com>2021-09-15 20:38:54 +0200
committerMarc Cornellà <hello@mcornella.com>2021-09-15 20:38:54 +0200
commit8784e88552ad7f6f6a9c149a739474e0b168a840 (patch)
tree9ec0ad41808f29fc1b3b0b7c5337d13df9e1760d /oh-my-zsh.sh
parenteb2eacaf0c46ace8e0eb3543199851a8249338fc (diff)
downloadzsh-8784e88552ad7f6f6a9c149a739474e0b168a840.tar.gz
zsh-8784e88552ad7f6f6a9c149a739474e0b168a840.tar.bz2
zsh-8784e88552ad7f6f6a9c149a739474e0b168a840.zip
fix(core): use `$HOME/.cache` if default cache dir is non-writable (#10193)
Fixes #10193
Diffstat (limited to 'oh-my-zsh.sh')
-rw-r--r--oh-my-zsh.sh7
1 files changed, 6 insertions, 1 deletions
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index 442972a9a..cea466100 100644
--- a/oh-my-zsh.sh
+++ b/oh-my-zsh.sh
@@ -7,7 +7,12 @@ if [[ -z "$ZSH_CACHE_DIR" ]]; then
ZSH_CACHE_DIR="$ZSH/cache"
fi
-# Create completions cache dir and add to $fpath
+# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
+if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
+ ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/ohmyzsh"
+fi
+
+# Create cache and completions dir and add to $fpath
mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)$ZSH_CACHE_DIR/completions]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)