include "equals" in the conditions
[rrq/nilfs2sss.git] / sss.sh
diff --git a/sss.sh b/sss.sh
index 085bffc481e03462e62c91b3e50a71b5d38288c2..1f253d3b5bcf0caba4dced57b4881589d1f31468 100755 (executable)
--- a/sss.sh
+++ b/sss.sh
@@ -34,9 +34,9 @@ YEARLY="$(date -d '-1 year' '+%Y-%m-%d %H:%M:%S')"
 MARK=( )
 function marksnap() {
     if [[ "${MARK[0]}" == "$1" ]] && [[ "${MARK[1]}" = "$2" ]] ; then
-       chcp cp $DEV ${MARKYEAR[2]}
+       chcp cp $DEV ${MARK[2]}
     fi
-    MARK=( "$1" "$2" $3 )
+    MARK=( "$1" "$2" "$3" )
 }
 
 { flock 9
@@ -45,16 +45,16 @@ function marksnap() {
   lscp -s $DEV | while read CNO DATE TIME REST ; do
       TS="$DATE $TIME"
       [ "$CNO" = "CNO" ] && continue
-      if [[ "$TS" > "$YEARLY" ]] ; then
+      if [[ "$TS" > "$YEARLY" ]] ; then
          marksnap YEAR "${DATE:0:4}" $CNO
-      elif [[ "$TS" > "$MONTHLY" ]]
+      elif [[ ! "$TS" > "$MONTHLY" ]] ; then
           marksnap MONTH "${DATE:5:2}" $CNO
-      elif [[ "$TS" > "$WEEKLY" ]] ; then
+      elif [[ "$TS" > "$WEEKLY" ]] ; then
           # For older than most recent week, keep last snapshot each week
           marksnap WEEK "$(( 7${DATE:8:2} / 7 - 100 ))" $CNO
-      elif [[ "$TS" > "$DAILY" ]] ; then
+      elif [[ "$TS" > "$DAILY" ]] ; then
           marksnap DAY "${DATE:8:2}" $CNO
-      elif [[ "$TS" > "$HOURLY" ]] ; then
+      elif [[ "$TS" > "$HOURLY" ]] ; then
           marksnap HOUR "${DATE:8:2}-${TIME:0:2}" $CNO
       else
          echo "$CNO $DATE $TIME within last hour"