diff --git a/tests/t9999-testsuite_example.sh b/tests/t9999-testsuite_example.sh index 24df132..9989fa9 100755 --- a/tests/t9999-testsuite_example.sh +++ b/tests/t9999-testsuite_example.sh @@ -85,10 +85,12 @@ TODO: $HOME/todo.txt archived. TODO: 5 of 5 tasks shown >>> todo.sh report +TODO: $HOME/todo.txt archived. TODO: Report file updated. 2009-02-13-04:40:00 5 1 >>> todo.sh report +TODO: $HOME/todo.txt archived. TODO: Report file updated. 2009-02-13-04:40:00 5 1 2009-02-13-04:40:00 5 1 diff --git a/todo.sh b/todo.sh index be65a46..4929551 100755 --- a/todo.sh +++ b/todo.sh @@ -367,18 +367,6 @@ getNewtodo() [ -z "$newtodo" ] && die "$(getPrefix "$2"): No updated task $item." } -archive() -{ - #defragment blank lines - sed -i.bak -e '/./!d' "$TODO_FILE" - [ $TODOTXT_VERBOSE -gt 0 ] && grep "^x " "$TODO_FILE" - grep "^x " "$TODO_FILE" >> "$DONE_FILE" - sed -i.bak '/^x /d' "$TODO_FILE" - if [ $TODOTXT_VERBOSE -gt 0 ]; then - echo "TODO: $TODO_FILE archived." - fi -} - replaceOrPrepend() { action=$1; shift @@ -950,7 +938,15 @@ case $action in ;; "archive" ) - archive;; + # defragment blank lines + sed -i.bak -e '/./!d' "$TODO_FILE" + [ $TODOTXT_VERBOSE -gt 0 ] && grep "^x " "$TODO_FILE" + grep "^x " "$TODO_FILE" >> "$DONE_FILE" + sed -i.bak '/^x /d' "$TODO_FILE" + if [ $TODOTXT_VERBOSE -gt 0 ]; then + echo "TODO: $TODO_FILE archived." + fi + ;; "del" | "rm" ) # replace deleted line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1 @@ -1052,7 +1048,9 @@ case $action in done if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then - archive + # Recursively invoke the script to allow overriding of the archive + # action. + "$TODO_FULL_SH" archive fi ;; @@ -1217,9 +1215,10 @@ note: PRIORITY must be anywhere from A to Z." ;; "report" ) - #archive first - sed '/^x /!d' "$TODO_FILE" >> "$DONE_FILE" - sed -i.bak '/^x /d' "$TODO_FILE" + # archive first + # Recursively invoke the script to allow overriding of the archive + # action. + "$TODO_FULL_SH" archive NUMLINES=$( sed -n '$ =' "$TODO_FILE" ) if [ ${NUMLINES:-0} = "0" ]; then