diff --git a/tests/t1700-depri.sh b/tests/t1700-depri.sh new file mode 100755 index 0000000..24bad09 --- /dev/null +++ b/tests/t1700-depri.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +test_description='basic depriority functionality +' +. ./test-lib.sh + +test_todo_session 'depriority usage' <>> todo.sh depri B B +usage: todo.sh depri ITEM# +=== 1 +EOF + +test_todo_session 'depriority nonexistant item' <>> todo.sh depri 42 +42: No such todo. +=== 1 +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 1 +1: smell the uppercase Roses +flowers @outside +TODO: 1 deprioritized. + +>>> todo.sh -p list +2 (A) notice the sunflowers +1 smell the uppercase Roses +flowers @outside +3 stop +-- +TODO: 3 of 3 tasks shown +EOF + +test_done diff --git a/todo.sh b/todo.sh index 3acdfca..2894b40 100755 --- a/todo.sh +++ b/todo.sh @@ -745,9 +745,9 @@ case $action in item=$2 errmsg="usage: $TODO_SH depri ITEM#" + [[ "$item" = +([0-9]) ]] || die "$errmsg" todo=$(sed "$item!d" "$TODO_FILE") [ -z "$todo" ] && die "$item: No such todo." - [[ "$item" = +([0-9]) ]] || die "$errmsg" sed -e $item"s/^(.) //" "$TODO_FILE" > /dev/null 2>&1