dda1154c80ec0b8ad02846240e4c5d701279b296

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #1655 from nubs/phing-and-cache-files

Improve portability of cache file detection for command targets

Diff

  1diff --git a/plugins/ant/ant.plugin.zsh b/plugins/ant/ant.plugin.zsh
  2index 691d4d2db51a09b5ce69c83d621f8e2cce008e28..45f2b06eb600511408934471ca4320f2497ab218 100644
  3--- a/plugins/ant/ant.plugin.zsh
  4+++ b/plugins/ant/ant.plugin.zsh
  5@@ -1,17 +1,7 @@
  6-stat -f%m . > /dev/null 2>&1
  7-if [ "$?" = 0 ]; then
  8-	stat_cmd=(stat -f%m)
  9-else
 10-	stat_cmd=(stat -L --format=%Y)
 11-fi
 12-
 13 _ant_does_target_list_need_generating () {
 14-  if [ ! -f .ant_targets ]; then return 0;
 15-  else
 16-    accurate=$($stat_cmd .ant_targets)
 17-    changed=$($stat_cmd build.xml)
 18-    return $(expr $accurate '>=' $changed)
 19-  fi
 20+  [ ! -f .ant_targets ] && return 0;
 21+  [ .ant_targets -nt build.xml ] && return 0;
 22+  return 1;
 23 }
 24 
 25 _ant () {
 26diff --git a/plugins/cake/cake.plugin.zsh b/plugins/cake/cake.plugin.zsh
 27index 1d0d196ee194a15027e405b9f737fc96bbc67fea..44cc47470200264729bd9e8d745683aa80037344 100644
 28--- a/plugins/cake/cake.plugin.zsh
 29+++ b/plugins/cake/cake.plugin.zsh
 30@@ -14,12 +14,9 @@ _cake_does_target_list_need_generating () {
 31 		return 1;
 32 	fi
 33 
 34-	if [ ! -f ${_cake_task_cache_file} ]; then return 0;
 35-	else
 36-		accurate=$(stat -f%m $_cake_task_cache_file)
 37-		changed=$(stat -f%m Cakefile)
 38-		return $(expr $accurate '>=' $changed)
 39-	fi
 40+	[ ! -f ${_cake_task_cache_file} ] && return 0;
 41+	[ ${_cake_task_cache_file} -nt Cakefile ] && return 0;
 42+	return 1;
 43 }
 44 
 45 _cake () {
 46@@ -33,4 +30,4 @@ _cake () {
 47 	fi
 48 }
 49 
 50-compdef _cake cake
 51+compdef _cake cake
 52diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh
 53index fc4c78c503c26ef2762cb1f84df3476670b1a84d..9229512f7570cd2faf650fea5e82e6ac0218381b 100644
 54--- a/plugins/gradle/gradle.plugin.zsh
 55+++ b/plugins/gradle/gradle.plugin.zsh
 56@@ -54,27 +54,14 @@ function in_gradle() {
 57     fi
 58 }
 59 
 60-############################################################################
 61-# Define the stat_cmd command based on platform behavior
 62-##########################################################################
 63-stat -f%m . > /dev/null 2>&1
 64-if [ "$?" = 0 ]; then
 65-	stat_cmd=(stat -f%m)
 66-else
 67-	stat_cmd=(stat -L --format=%Y)
 68-fi
 69-
 70 ############################################################################## Examine the build.gradle file to see if its
 71 # timestamp has changed, and if so, regen
 72 # the .gradle_tasks cache file
 73 ############################################################################
 74 _gradle_does_task_list_need_generating () {
 75-  if [ ! -f .gradletasknamecache ]; then return 0;
 76-  else
 77-    accurate=$($stat_cmd .gradletasknamecache)
 78-    changed=$($stat_cmd build.gradle)
 79-    return $(expr $accurate '>=' $changed)
 80-  fi
 81+  [ ! -f .gradletasknamecache ] && return 0;
 82+  [ .gradletasknamecache -nt build.gradle ] && return 0;
 83+  return 1;
 84 }
 85 
 86 
 87diff --git a/plugins/phing/phing.plugin.zsh b/plugins/phing/phing.plugin.zsh
 88index 8f4adca08720ffdffc8ca258637d399dcdef8e37..795f1db852874932e0331bb5bcb9e14ba59bdd50 100644
 89--- a/plugins/phing/phing.plugin.zsh
 90+++ b/plugins/phing/phing.plugin.zsh
 91@@ -1,16 +1,13 @@
 92 _phing_does_target_list_need_generating () {
 93-  if [ ! -f .phing_targets ]; then return 0;
 94-  else
 95-    accurate=$(stat -f%m .phing_targets)
 96-    changed=$(stat -f%m build.xml)
 97-    return $(expr $accurate '>=' $changed)
 98-  fi
 99+  [ ! -f .phing_targets ] && return 0;
100+  [ .phing_targets -nt build.xml ] && return 0;
101+  return 1;
102 }
103 
104 _phing () {
105   if [ -f build.xml ]; then
106     if _phing_does_target_list_need_generating; then
107-      phing -l |grep -v ":" |grep -v "^$"|grep -v "\-" > .phing_targets
108+      phing -l |grep -v ":$" |grep -v "^-*$" > .phing_targets
109     fi
110     compadd `cat .phing_targets`
111   fi