diff --git a/tests/t2200-no-done-report-files.sh b/tests/t2200-no-done-report-files.sh new file mode 100755 index 0000000..8c35e86 --- /dev/null +++ b/tests/t2200-no-done-report-files.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# + +test_description='todo.sh configuration with a sole todo.txt data file. + +This test covers turning off done.txt and report.txt, and +checks that no such empty files are created. +' +. ./test-lib.sh + +cat > test.cfg << EOF +export TODO_DIR=. +export TODO_FILE="\$TODO_DIR/todo.txt" +export DONE_FILE=/dev/null +export REPORT_FILE=/dev/null +export TMP_FILE="\$TODO_DIR/todo.tmp" +touch used_config +EOF + +test_todo_session 'invoke todo.sh' <>> todo.sh -d test.cfg add notice the daisies +1 notice the daisies +TODO: 1 added. +EOF + +test_expect_success 'the todo file has been created' '[ -e todo.txt ]' +test_expect_success 'no done file has been created' '[ ! -e done.txt ]' +test_expect_success 'no report file has been created' '[ ! -e report.txt ]' + +test_todo_session 'perform archive' <>> todo.sh -A -d test.cfg do 1 +1 x 2009-02-13 notice the daisies +TODO: 1 marked as done. +x 2009-02-13 notice the daisies +TODO: ./todo.txt archived. +EOF + +test_expect_success 'no done file has been created by the archiving' '[ ! -e done.txt ]' + +test_todo_session 'perform report' <>> todo.sh -d test.cfg report +TODO: ./todo.txt archived. +2009-02-13T04:40:00 0 0 +TODO: Report file updated. +EOF + +test_expect_success 'no report file has been created by the reporting' '[ ! -e report.txt ]' + +test_done diff --git a/todo.sh b/todo.sh index 25078fb..7cecd7c 100755 --- a/todo.sh +++ b/todo.sh @@ -709,9 +709,9 @@ ACTION=${1:-$TODOTXT_DEFAULT_ACTION} [ -d "$TODO_DIR" ] || dieWithHelp "$1" "Fatal Error: $TODO_DIR is not a directory" ( cd "$TODO_DIR" ) || dieWithHelp "$1" "Fatal Error: Unable to cd to $TODO_DIR" -[ -f "$TODO_FILE" ] || cp /dev/null "$TODO_FILE" -[ -f "$DONE_FILE" ] || cp /dev/null "$DONE_FILE" -[ -f "$REPORT_FILE" ] || cp /dev/null "$REPORT_FILE" +[ -f "$TODO_FILE" -o -c "$TODO_FILE" ] || > "$TODO_FILE" +[ -f "$DONE_FILE" -o -c "$DONE_FILE" ] || > "$DONE_FILE" +[ -f "$REPORT_FILE" -o -c "$REPORT_FILE" ] || > "$REPORT_FILE" if [ $TODOTXT_PLAIN = 1 ]; then for clr in ${!PRI_@}; do