7deda85f8cf7fb3c2f36b771a2e8bd70a28bf0b3

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Fix upgrade_oh_my_zsh function deprecation

Diff

 1diff --git a/lib/cli.zsh b/lib/cli.zsh
 2index 3c09cdab82c45603ff3130009249389274d97d3e..d8203f271dd356e42d792e2f6e29d68f97d5830a 100644
 3--- a/lib/cli.zsh
 4+++ b/lib/cli.zsh
 5@@ -201,10 +201,14 @@ function _omz::pr::test {
 6 }
 7 
 8 function _omz::update {
 9+    # Run update script
10     env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"
11     # Update last updated file
12     zmodload zsh/datetime
13     echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update"
14     # Remove update lock if it exists
15     command rm -rf "$ZSH/log/update.lock"
16+    # Restart the zsh session
17+    _omz::log info "restarting the zsh session..."
18+    [[ -z "$SHELL" ]] && exec ${SHELL#-} || exec zsh
19 }
20diff --git a/lib/functions.zsh b/lib/functions.zsh
21index e85b867a56824b9bf11e86a772340ef85ced21dd..0556aeb2976c005807b0a3490004c991a3b326f5 100644
22--- a/lib/functions.zsh
23+++ b/lib/functions.zsh
24@@ -7,8 +7,20 @@ function uninstall_oh_my_zsh() {
25 }
26 
27 function upgrade_oh_my_zsh() {
28-  echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color"
29-  omz update
30+  if (( $+functions[_omz::update] )); then
31+    echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color"
32+  fi
33+
34+  # Run update script
35+  env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"
36+  # Update last updated file
37+  zmodload zsh/datetime
38+  echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update"
39+  # Remove update lock if it exists
40+  command rm -rf "$ZSH/log/update.lock"
41+  # Restart the zsh session
42+  _omz::log info "restarting the zsh session..."
43+  [[ -z "$SHELL" ]] && exec ${SHELL#-} || exec zsh
44 }
45 
46 function take() {