Skip to content
This repository
Browse code

FIX: Replacement with priority and date doesn't replace existing date.

  • Loading branch information...
commit 24d0fb003a8ef486c37a53cb80d28872922e206c 1 parent ebe6a40
Ingo Karkat inkarkat authored

Showing 2 changed files with 11 additions and 3 deletions. Show diff stats Hide diff stats

  1. +8 0 tests/t1100-replace.sh
  2. +3 3 todo.sh
8 tests/t1100-replace.sh
@@ -164,4 +164,12 @@ TODO: Replaced task with:
164 164 1 (A) 2010-07-04 this also has a new date
165 165 EOF
166 166
  167 +echo '2009-02-13 this is just a new one' > todo.txt
  168 +test_todo_session 'replace with prepended priority and date replaces existing date' <<EOF
  169 +>>> todo.sh replace 1 '(B) 2010-07-04 this also has a new date'
  170 +1 2009-02-13 this is just a new one
  171 +TODO: Replaced task with:
  172 +1 (B) 2010-07-04 this also has a new date
  173 +EOF
  174 +
167 175 test_done
6 todo.sh
@@ -395,9 +395,9 @@ replaceOrPrepend()
395 395 priority=$(sed -e "$item!d" -e $item's/^\((.) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\1/' "$TODO_FILE")
396 396 prepdate=$(sed -e "$item!d" -e $item's/^\((.) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\2/' "$TODO_FILE")
397 397
398   - if [ "$prepdate" -a "$action" = "replace" ] && [ "$(echo "$input"|sed -e 's/^\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\}\)\{0,1\}.*/\1/')" ]; then
399   - # If the replaced text starts with a date, it will replace the existing
400   - # date, too.
  398 + if [ "$prepdate" -a "$action" = "replace" ] && [ "$(echo "$input"|sed -e 's/^\((.) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\1\2/')" ]; then
  399 + # If the replaced text starts with a [priority +] date, it will replace
  400 + # the existing date, too.
401 401 prepdate=
402 402 fi
403 403

0 comments on commit 24d0fb0

Please sign in to comment.
Something went wrong with that request. Please try again.