diff --git a/tests/t9999-testsuite_example.sh b/tests/t9999-testsuite_example.sh index 689fc6d..f350118 100755 --- a/tests/t9999-testsuite_example.sh +++ b/tests/t9999-testsuite_example.sh @@ -167,7 +167,7 @@ TODO: Report file updated. >>> todo.sh report 2009-02-13T04:40:00 5 2 -TODO: Report file updated. +TODO: Report file is up-to-date. >>> todo.sh remdup Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description] diff --git a/todo.sh b/todo.sh index c135d97..34faebf 100755 --- a/todo.sh +++ b/todo.sh @@ -1193,9 +1193,18 @@ note: PRIORITY must be anywhere from A to Z." TOTAL=$( sed -n '$ =' "$TODO_FILE" ) TDONE=$( sed -n '$ =' "$DONE_FILE" ) - echo "$(date +%Y-%m-%dT%T) ${TOTAL:-0} ${TDONE:-0}" >> "$REPORT_FILE" - sed -ne '$p' "$REPORT_FILE" - [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated." + NEWDATA="${TOTAL:-0} ${TDONE:-0}" + LASTREPORT=$(sed -ne '$p' "$REPORT_FILE") + LASTDATA=${LASTREPORT#* } # Strip timestamp. + if [ "$LASTDATA" = "$NEWDATA" ]; then + echo "$LASTREPORT" + [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file is up-to-date." + else + NEWREPORT="$(date +%Y-%m-%dT%T) ${NEWDATA}" + echo "${NEWREPORT}" >> "$REPORT_FILE" + echo "${NEWREPORT}" + [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated." + fi ;; * )