From ddd3e9711bb110597dc3d683ce0d7debaf33d8b8 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Tue, 10 May 2011 11:52:38 +0200 Subject: [PATCH] depri: Check for unprioritized task and print message. The existing check didn't do much good, and one could deprioritize any normal task without notice. Instead, check that the task to be deprioritized actually has a priority and alert via "TODO: 42 is not prioritized." if that is not the case. --- tests/t1700-depri.sh | 26 ++++++++++++++++++++++++++ todo.sh | 7 ++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/tests/t1700-depri.sh b/tests/t1700-depri.sh index 5c2424d..9fcbf8d 100755 --- a/tests/t1700-depri.sh +++ b/tests/t1700-depri.sh @@ -68,4 +68,30 @@ TODO: 2 deprioritized. TODO: 3 of 3 tasks shown EOF +cat > todo.txt <>> todo.sh -p list +2 (A) notice the sunflowers +1 (B) smell the uppercase Roses +flowers @outside +3 stop +-- +TODO: 3 of 3 tasks shown + +>>> todo.sh depri 3 2 +TODO: 3 is not prioritized. +2 notice the sunflowers +TODO: 2 deprioritized. + +>>> todo.sh -p list +1 (B) smell the uppercase Roses +flowers @outside +2 notice the sunflowers +3 stop +-- +TODO: 3 of 3 tasks shown +EOF + test_done diff --git a/todo.sh b/todo.sh index d59092a..281c6a1 100755 --- a/todo.sh +++ b/todo.sh @@ -921,10 +921,7 @@ case $action in todo=$(sed "$item!d" "$TODO_FILE") [ -z "$todo" ] && die "TODO: No task $item." - sed -e $item"s/^(.) //" "$TODO_FILE" > /dev/null 2>&1 - - if [ "$?" -eq 0 ]; then - #it's all good, continue + if sed "$item!d" "$TODO_FILE" | grep "^(.) " > /dev/null; then sed -i.bak -e $item"s/^(.) //" "$TODO_FILE" if [ $TODOTXT_VERBOSE -gt 0 ]; then NEWTODO=$(sed "$item!d" "$TODO_FILE") @@ -932,7 +929,7 @@ case $action in echo "TODO: $item deprioritized." fi else - die "$errmsg" + echo "TODO: $item is not prioritized." fi done ;;