changeset 7:1e8e782fccab

Merge together the Linux and Darwin tests for the subversion status command, setting the proper commands as variables instead of hardcoding for each arch.
author huston@80426f53-59d1-405d-934b-f07cd76f4a1a
date Mon, 13 Apr 2009 03:38:53 +0000
parents f5b253e17e34
children aa5e55aa62ef
files .bash_profile
diffstat 1 files changed, 29 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/.bash_profile	Mon Apr 13 02:31:48 2009 +0000
+++ b/.bash_profile	Mon Apr 13 03:38:53 2009 +0000
@@ -14,24 +14,42 @@
 # source ~/.bashrc above I don't think we have to here also.
 # export BASH_ENV=$HOME/.bashrc
 
+# These lines are helpful if you routinely might login without passing an
+# ssh-agent's authentication through.  This way when you login, an agent is
+# exec'd for you (the corresponding lines in .bash_logout should kill the
+# agent when you logout, however they sometimes fail such as when killing your
+# shell without a proper logout or closing the connection).  I left it here,
+# though I personally don't use/need it anymore.
+
 #if [ "X$SSH_AUTH_SOCK" = "X" ] ; then
 #   eval `/usr/bin/ssh-agent`
 #fi
 
-# Check timestamp of the file '$HOME/.dotfilets'.  If it's older than a week,
-# run a 'svn st -u' and touch it; this way we check once per week to see if we
-# forgot to pull down an updated version.  I wish that command would change
-# its exit value based on if there's updates or not, would be easier to
-# automate this quietly.
+# This part is quite useful if you have your dotfiles stored in subversion
+# (though it could be edited fairly easily for any other version control
+# system I'm sure).  We check the timestamp of the file '$HOME/.dotfilets'.
+# If it's older than a week, run a 'svn st -u' and touch it; this way we check
+# once per week to see if we forgot to pull down an updated version.
+
+# First set $STAT and $DATE since the syntax of the commands is different
+# between Linux and Mac OS X.  If this is run elsewhere, the eval will be
+# false and the test not done below, so it's safe to not bother checking for
+# zero-length variables on the test - it just won't run the svn status, so you
+# won't be prompted if there's newer files available in your repository.
 
 [[ `uname` == "Darwin" ]] && {
-   [[ ! -f $HOME/.dotfilets || \
-      `stat -f %m -t %s .dotfilets` -lt `date -v -1w +%s` ]] && {
-      echo Dotfiles last checked over a week ago, running a status test.
-      svn st -u && touch $HOME/.dotfilets
-   }
+   STAT="stat -f %m -t %s $HOME/.dotfilets"
+   DATE="date -v -1w +%s"
 }
 
 [[ `uname` == "Linux" ]] && {
-# Linux tests here
+   STAT="stat -c %Y $HOME/.dotfilets"
+   DATE="date -d \"1 week ago\" +%s"
 }
+
+[[ ! -f $HOME/.dotfilets || \
+   `eval $STAT` -lt `eval $DATE` ]] && {
+   echo Dotfiles last checked over a week ago, running a status test.
+   echo Ctrl-C to abort, and test will be run again on next login.
+   svn st -u && touch $HOME/.dotfilets
+}