diff --git a/tests/t1900-archive.sh b/tests/t1900-archive.sh index af95ba0c..9b5f00fb 100755 --- a/tests/t1900-archive.sh +++ b/tests/t1900-archive.sh @@ -32,4 +32,9 @@ test_todo_session 'list after archive' <>> todo.sh archive +TODO: $HOME/todo.txt does not contain any done tasks. +EOF + test_done diff --git a/tests/t1950-report.sh b/tests/t1950-report.sh index 6b88d658..9546e043 100755 --- a/tests/t1950-report.sh +++ b/tests/t1950-report.sh @@ -16,7 +16,7 @@ EOF test_todo_session 'create new report' <>> todo.sh report -TODO: $HOME/todo.txt archived. +TODO: $HOME/todo.txt does not contain any done tasks. 2009-02-13T04:40:00 5 0 TODO: Report file updated. @@ -38,7 +38,7 @@ x 2009-02-13 smell the coffee +wakeup TODO: $HOME/todo.txt archived. >>> todo.sh report -TODO: $HOME/todo.txt archived. +TODO: $HOME/todo.txt does not contain any done tasks. 2009-02-13T04:40:00 4 1 TODO: Report file updated. @@ -83,7 +83,7 @@ test_todo_session 'report is unchanged when no changes' <>> todo.sh report -TODO: $HOME/todo.txt archived. +TODO: $HOME/todo.txt does not contain any done tasks. 2009-02-13T04:40:00 3 2 TODO: Report file is up-to-date. diff --git a/tests/t2200-no-done-report-files.sh b/tests/t2200-no-done-report-files.sh index 306fc4d2..feb74304 100755 --- a/tests/t2200-no-done-report-files.sh +++ b/tests/t2200-no-done-report-files.sh @@ -38,7 +38,7 @@ test_expect_success 'no done file has been created by the archiving' '[ ! -e don test_todo_session 'perform report' <>> todo.sh -d test.cfg report -TODO: ./todo.txt archived. +TODO: ./todo.txt does not contain any done tasks. 2009-02-13T04:40:00 0 0 TODO: Report file updated. EOF diff --git a/tests/t9999-testsuite_example.sh b/tests/t9999-testsuite_example.sh index cdc7a901..c0aa6b09 100755 --- a/tests/t9999-testsuite_example.sh +++ b/tests/t9999-testsuite_example.sh @@ -85,7 +85,7 @@ TODO: $HOME/todo.txt archived. TODO: 5 of 5 tasks shown >>> todo.sh report -TODO: $HOME/todo.txt archived. +TODO: $HOME/todo.txt does not contain any done tasks. 2009-02-13T04:40:00 5 1 TODO: Report file updated. diff --git a/todo.sh b/todo.sh index a55310d0..130ed3f2 100755 --- a/todo.sh +++ b/todo.sh @@ -1172,11 +1172,16 @@ case $action in "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." + if grep "^x " "$TODO_FILE" >> "$DONE_FILE"; then + [ "$TODOTXT_VERBOSE" -gt 0 ] && grep "^x " "$TODO_FILE" + sed -i.bak '/^x /d' "$TODO_FILE" + if [ "$TODOTXT_VERBOSE" -gt 0 ]; then + echo "TODO: $TODO_FILE archived." + fi + else + if [ "$TODOTXT_VERBOSE" -gt 0 ]; then + echo "TODO: $TODO_FILE does not contain any done tasks." + fi fi ;;