8784e88552ad7f6f6a9c149a739474e0b168a840

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

fix(core): use `$HOME/.cache` if default cache dir is non-writable (#10193)

Fixes #10193

Diff

 1diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
 2index 442972a9a9fefad09a8de9465f1f6ba66e4f2f5c..cea466100ee4cbc83cb82973aa939b4736e09c19 100644
 3--- a/oh-my-zsh.sh
 4+++ b/oh-my-zsh.sh
 5@@ -7,7 +7,12 @@ if [[ -z "$ZSH_CACHE_DIR" ]]; then
 6   ZSH_CACHE_DIR="$ZSH/cache"
 7 fi
 8 
 9-# Create completions cache dir and add to $fpath
10+# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
11+if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
12+  ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/ohmyzsh"
13+fi
14+
15+# Create cache and completions dir and add to $fpath
16 mkdir -p "$ZSH_CACHE_DIR/completions"
17 (( ${fpath[(Ie)$ZSH_CACHE_DIR/completions]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
18