Merge pull request #116 from inkarkat/enh-allow-null-files

Allow configuring null data files and then don't create them.
This commit is contained in:
Gina Trapani
2013-11-19 14:08:01 -08:00
2 changed files with 52 additions and 3 deletions

View File

@@ -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' <<EOF
>>> 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' <<EOF
>>> 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' <<EOF
>>> 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

View File

@@ -709,9 +709,9 @@ ACTION=${1:-$TODOTXT_DEFAULT_ACTION}
[ -d "$TODO_DIR" ] || dieWithHelp "$1" "Fatal Error: $TODO_DIR is not a directory" [ -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" ( cd "$TODO_DIR" ) || dieWithHelp "$1" "Fatal Error: Unable to cd to $TODO_DIR"
[ -f "$TODO_FILE" ] || cp /dev/null "$TODO_FILE" [ -f "$TODO_FILE" -o -c "$TODO_FILE" ] || > "$TODO_FILE"
[ -f "$DONE_FILE" ] || cp /dev/null "$DONE_FILE" [ -f "$DONE_FILE" -o -c "$DONE_FILE" ] || > "$DONE_FILE"
[ -f "$REPORT_FILE" ] || cp /dev/null "$REPORT_FILE" [ -f "$REPORT_FILE" -o -c "$REPORT_FILE" ] || > "$REPORT_FILE"
if [ $TODOTXT_PLAIN = 1 ]; then if [ $TODOTXT_PLAIN = 1 ]; then
for clr in ${!PRI_@}; do for clr in ${!PRI_@}; do