diff --git a/tests/t1900-archive.sh b/tests/t1900-archive.sh new file mode 100755 index 0000000..5ac9316 --- /dev/null +++ b/tests/t1900-archive.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +test_description='archive functionality + +Ensure we can append items successfully. +' +. ./test-lib.sh + +cat >> todo.txt<>> todo.sh archive +x done +TODO: $HOME/todo.txt archived. +EOF + +test_todo_session 'list after archive' <>> todo.sh ls +4 four +1 one +3 three +2 two +-- +TODO: 4 of 4 tasks shown +EOF + +test_done diff --git a/todo.sh b/todo.sh index 337bbea..f945fa6 100755 --- a/todo.sh +++ b/todo.sh @@ -371,7 +371,7 @@ archive() grep "^x " "$TODO_FILE" >> "$DONE_FILE" sed -i.bak '/^x /d' "$TODO_FILE" cp "$TODO_FILE" "$TMP_FILE" - sed -n 'G; s/\n/&&/; /^\([ ~-]*\n\).*\n\1/d; s/\n//; h; P' "$TMP_FILE" > "$TODO_FILE" + sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' "$TMP_FILE" > "$TODO_FILE" if [ $TODOTXT_VERBOSE -gt 0 ]; then echo "TODO: $TODO_FILE archived." fi