cb55161470e051e520bad388c20e32d43cfca973

Author
leycec <leycec@gmail.com>
Committer
leycec <leycec@gmail.com>
Date

Message

Completion insecurities handled on startup.

Completion-dependent directories with insecure permissions or ownership (e.g.,
group or other writability) are now detected, reported, and sanitized on OMZ
startup rather than unsafely ignored -- which resulted in effectively empty
completion caches and obscure compdef() errors resembling
"compdef: unknown command or service: git".

This fixes long-standing issues #630, #3356, and #3455 and related Babun issues
159, 281, and 322 -- and probably numerous other duplicates.

Diff

 1diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
 2index ec64c240f0203b64b1d32fe6da2ae657e93329f1..9dde78caa529fb063f6f5b1ee25754d3eabed0d4 100644
 3--- a/oh-my-zsh.sh
 4+++ b/oh-my-zsh.sh
 5@@ -8,6 +8,9 @@ fi
 6 # add a function path
 7 fpath=($ZSH/functions $ZSH/completions $fpath)
 8 
 9+# Load all stock functions (from $fpath files) called below.
10+autoload -U compaudit compinit
11+
12 # Set ZSH_CUSTOM to the path where your custom config files
13 # and plugins exists, or else we will use the default custom/
14 if [[ -z "$ZSH_CUSTOM" ]]; then
15@@ -64,9 +67,14 @@ if [ -z "$ZSH_COMPDUMP" ]; then
16   ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
17 fi
18 
19-# Load and run compinit
20-autoload -U compinit
21-compinit -i -d "${ZSH_COMPDUMP}"
22+# If completion insecurities exist, warn the user without enabling completions.
23+if ! compaudit &>/dev/null; then
24+  # This function resides in the "lib/compfix.zsh" script sourced above.
25+  handle_completion_insecurities
26+# Else, enable and cache completions to the desired file.
27+else
28+  compinit -d "${ZSH_COMPDUMP}"
29+fi
30 
31 # Load all of the plugins that were defined in ~/.zshrc
32 for plugin ($plugins); do