Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updating check_for_upgrade script to fix issue when the LAST_EPOCH fi…

…le/value got corrupted. Closes #32
  • Loading branch information...
commit 41f13ccb0a5d04496605f69b7ae284d9d639b625 1 parent 473dd3b
Robby Russell authored December 12, 2009

Showing 1 changed file with 15 additions and 9 deletions. Show diff stats Hide diff stats

  1. 24  tools/check_for_upgrade.sh
24  tools/check_for_upgrade.sh
... ...
@@ -1,11 +1,22 @@
1 1
 #!/bin/sh
2 2
 
3  
-current_epoch=$(($(date +%s) / 60 / 60 / 24))
  3
+function _current_epoch() {
  4
+  echo $(($(date +%s) / 60 / 60 / 24))
  5
+}
  6
+
  7
+function _update_zsh_update() {
  8
+  echo "LAST_EPOCH=$(_current_epoch)" > ~/.zsh-update
  9
+}
4 10
 
5 11
 if [ -f ~/.zsh-update ]
6 12
 then
7 13
   . ~/.zsh-update
8  
-  epoch_diff=$(($current_epoch - $LAST_EPOCH))
  14
+
  15
+  if [[ -z "$LAST_EPOCH" ]]; then
  16
+    _update_zsh_update && return 0;
  17
+  fi
  18
+
  19
+  epoch_diff=$((${_current_epoch} - $LAST_EPOCH))
9 20
   if [ $epoch_diff -gt 6 ]
10 21
   then
11 22
     echo "[Oh My Zsh] Would you like to check for updates?"
@@ -15,14 +26,9 @@ then
15 26
     then
16 27
       /bin/sh $ZSH/tools/upgrade.sh
17 28
     fi
18  
-
19  
-    # Set the last epoch to the current so that we don't ask for another week
20  
-    echo "LAST_EPOCH=${current_epoch}" > ~/.zsh-update
21 29
   fi
22  
-else
23  
-  # TODO: refactor this so remove duplicates
24  
-  # Create the ~/.zsh-update file with the current epoch info
25  
-  echo "LAST_EPOCH=${current_epoch}" > ~/.zsh-update
26 30
 fi
27 31
 
  32
+# update the zsh file
  33
+_update_zsh_update
28 34
 

0 notes on commit 41f13cc

Please sign in to comment.
Something went wrong with that request. Please try again.