summaryrefslogtreecommitdiff
path: root/oh-my-zsh.sh
diff options
context:
space:
mode:
authorMarc Cornellà <marc.cornella@live.com>2020-06-02 11:45:23 +0200
committerMarc Cornellà <marc.cornella@live.com>2020-06-02 11:45:50 +0200
commit0e12ebb42def5729f79b5f5d2703829faa6a9643 (patch)
treecd90b634887dbcee0a448c7e1f207b3105e0c81a /oh-my-zsh.sh
parent93cc3964e2d265ab0571298d69d2eed0a65d13f2 (diff)
downloadzsh-0e12ebb42def5729f79b5f5d2703829faa6a9643.tar.gz
zsh-0e12ebb42def5729f79b5f5d2703829faa6a9643.tar.bz2
zsh-0e12ebb42def5729f79b5f5d2703829faa6a9643.zip
init: use grep for zcompdump metadata check
Closes #8981
Diffstat (limited to 'oh-my-zsh.sh')
-rw-r--r--oh-my-zsh.sh18
1 files changed, 11 insertions, 7 deletions
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index 435febc6d..8b4c778d6 100644
--- a/oh-my-zsh.sh
+++ b/oh-my-zsh.sh
@@ -62,13 +62,13 @@ if [ -z "$ZSH_COMPDUMP" ]; then
fi
# Construct zcompdump OMZ metadata
-zcompdump_metadata="\
-#omz revision: $(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)
-#omz fpath: $fpath\
-"
+zcompdump_revision="#omz revision: $(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)"
+zcompdump_fpath="#omz fpath: $fpath"
# Delete the zcompdump file if OMZ zcompdump metadata changed
-if ! cmp -s <(command grep '^#omz' "$ZSH_COMPDUMP" 2>/dev/null) <(echo "$zcompdump_metadata"); then
+if ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null \
+ || ! command grep -q -Fx "$zcompdump_fpath" "$ZSH_COMPDUMP" 2>/dev/null; then
+ echo zcompdump changed
command rm -f "$ZSH_COMPDUMP"
zcompdump_refresh=1
fi
@@ -86,10 +86,14 @@ fi
# Append zcompdump metadata if missing
if (( $zcompdump_refresh )); then
- echo "\n$zcompdump_metadata" | tee -a "$ZSH_COMPDUMP" &>/dev/null
+ cat >>| "$ZSH_COMPDUMP" <<EOF
+
+$zcompdump_revision
+$zcompdump_fpath
+EOF
fi
-unset zcompdump_metadata zcompdump_refresh
+unset zcompdump_revision zcompdump_fpath zcompdump_refresh
# Load all of the config files in ~/oh-my-zsh that end in .zsh