Bug Fix: do: no safeguard to do twice
Tests item is not marked done before attempting to mark item as "done".
This commit is contained in:
@@ -69,4 +69,12 @@ TODO: $HOME/todo.txt archived.
|
|||||||
TODO: 3 of 3 tasks shown from $HOME/todo.txt
|
TODO: 3 of 3 tasks shown from $HOME/todo.txt
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
test_todo_session 'fail multiple do attempts' <<EOF
|
||||||
|
>>> todo.sh -a do 3
|
||||||
|
3: x 2009-02-13 stop
|
||||||
|
TODO: 3 marked as done.
|
||||||
|
|
||||||
|
>>> todo.sh -a do 3
|
||||||
|
3 is already marked done
|
||||||
|
EOF
|
||||||
test_done
|
test_done
|
||||||
|
|||||||
5
todo.sh
5
todo.sh
@@ -705,6 +705,8 @@ case $action in
|
|||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ -z "$todo" ] && die "$item: No such todo."
|
[ -z "$todo" ] && die "$item: No such todo."
|
||||||
|
|
||||||
|
# Check if this item has already been done
|
||||||
|
if [ `echo $todo | grep -c "^x "` -eq 0 ] ; then
|
||||||
now=`date '+%Y-%m-%d'`
|
now=`date '+%Y-%m-%d'`
|
||||||
# remove priority once item is done
|
# remove priority once item is done
|
||||||
sed -i.bak $item"s/^(.) //" "$TODO_FILE"
|
sed -i.bak $item"s/^(.) //" "$TODO_FILE"
|
||||||
@@ -712,6 +714,9 @@ case $action in
|
|||||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo"
|
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo"
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item marked as done."
|
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item marked as done."
|
||||||
|
else
|
||||||
|
echo "$item is already marked done"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then
|
if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user