eabec36586f990b883e7dbf4583e6d86ac46c7ea

Author
Carlo Sala <carlosalag@protonmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

style(init): use consistent code style in init script (#10601)

Diff

This diff is truncated to protect this page.

  1diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
  2index b388b341d4deb00c876a268c772b5dffcd846029..ab32ee9d3ea6282271462e7cbe36b5defbf17652 100644
  3--- a/oh-my-zsh.sh
  4+++ b/oh-my-zsh.sh
  5@@ -57,14 +57,14 @@ mkdir -p "$ZSH_CACHE_DIR/completions"
  6 (( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
  7 
  8 # Check for updates on initial load...
  9-if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
 10-  source $ZSH/tools/check_for_upgrade.sh
 11+if [[ "$DISABLE_AUTO_UPDATE" != true ]]; then
 12+  source "$ZSH/tools/check_for_upgrade.sh"
 13 fi
 14 
 15 # Initializes Oh My Zsh
 16 
 17 # add a function path
 18-fpath=($ZSH/functions $ZSH/completions $fpath)
 19+fpath=("$ZSH/functions" "$ZSH/completions" $fpath)
 20 
 21 # Load all stock functions (from $fpath files) called below.
 22 autoload -U compaudit compinit
 23@@ -75,7 +75,6 @@ if [[ -z "$ZSH_CUSTOM" ]]; then
 24     ZSH_CUSTOM="$ZSH/custom"
 25 fi
 26 
 27-
 28 is_plugin() {
 29   local base_dir=$1
 30   local name=$2
 31@@ -86,10 +85,10 @@ is_plugin() {
 32 # Add all defined plugins to fpath. This must be done
 33 # before running compinit.
 34 for plugin ($plugins); do
 35-  if is_plugin $ZSH_CUSTOM $plugin; then
 36-    fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
 37-  elif is_plugin $ZSH $plugin; then
 38-    fpath=($ZSH/plugins/$plugin $fpath)
 39+  if is_plugin "$ZSH_CUSTOM" "$plugin"; then
 40+    fpath=("$ZSH_CUSTOM/plugins/$plugin" $fpath)
 41+  elif is_plugin "$ZSH" "$plugin"; then
 42+    fpath=("$ZSH/plugins/$plugin" $fpath)
 43   else
 44     echo "[oh-my-zsh] plugin '$plugin' not found"
 45   fi
 46@@ -98,14 +97,14 @@ done
 47 # Figure out the SHORT hostname
 48 if [[ "$OSTYPE" = darwin* ]]; then
 49   # macOS's $HOST changes with dhcp, etc. Use ComputerName if possible.
 50-  SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/}
 51+  SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST="${HOST/.*/}"
 52 else
 53-  SHORT_HOST=${HOST/.*/}
 54+  SHORT_HOST="${HOST/.*/}"
 55 fi
 56 
 57 # Save the location of the current completion dump file.
 58-if [ -z "$ZSH_COMPDUMP" ]; then
 59-  ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
 60+if [[ -z "$ZSH_COMPDUMP" ]]; then
 61+  ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
 62 fi
 63 
 64 # Construct zcompdump OMZ metadata
 65@@ -119,15 +118,15 @@ if ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null \
 66   zcompdump_refresh=1
 67 fi
 68 
 69-if [[ $ZSH_DISABLE_COMPFIX != true ]]; then
 70-  source $ZSH/lib/compfix.zsh
 71+if [[ "$ZSH_DISABLE_COMPFIX" != true ]]; then
 72+  source "$ZSH/lib/compfix.zsh"
 73   # If completion insecurities exist, warn the user
 74   handle_completion_insecurities
 75   # Load only from secure directories
 76-  compinit -i -C -d "${ZSH_COMPDUMP}"
 77+  compinit -i -C -d "$ZSH_COMPDUMP"
 78 else
 79   # If the user wants it, load from all found directories
 80-  compinit -u -C -d "${ZSH_COMPDUMP}"
 81+  compinit -u -C -d "$ZSH_COMPDUMP"
 82 fi
 83 
 84 # Append zcompdump metadata if missing
 85@@ -140,40 +139,48 @@ $zcompdump_revision
 86 $zcompdump_fpath
 87 EOF
 88 fi
 89-
 90 unset zcompdump_revision zcompdump_fpath zcompdump_refresh
 91 
 92-
 93 # Load all of the config files in ~/oh-my-zsh that end in .zsh
 94 # TIP: Add files you don't want in git to .gitignore
 95-for config_file ($ZSH/lib/*.zsh); do
 96-  custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
 97-  [ -f "${custom_config_file}" ] && config_file=${custom_config_file}
 98-  source $config_file
 99+for config_file ("$ZSH"/lib/*.zsh); do
100+  custom_config_file="$ZSH_CUSTOM/lib/${config_file:t}"
101+  [[ -f "$custom_config_file" ]] && config_file="$custom_config_file"
102+  source "$config_file"
103 done
104+unset custom_config_file