From c52d9c33af385bfea8db203d061725a4cb3f4a54 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 4 Jun 2010 04:13:17 +0800 Subject: [PATCH 1/4] Removed unnecessary echo within echo. --- todo.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/todo.sh b/todo.sh index 50f8e05..f8c4c5e 100755 --- a/todo.sh +++ b/todo.sh @@ -760,7 +760,7 @@ case $action in sed -i.bak -e $item"s/^(.) //" "$TODO_FILE" [ $TODOTXT_VERBOSE -gt 0 ] && { NEWTODO=$(sed "$item!d" "$TODO_FILE") - echo "`echo "$item: $NEWTODO"`" + echo "$item: $NEWTODO" echo "TODO: $item deprioritized." } else @@ -982,7 +982,7 @@ note: PRIORITY must be anywhere from A to Z." sed -i.bak -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE" [ $TODOTXT_VERBOSE -gt 0 ] && { NEWTODO=$(sed "$item!d" "$TODO_FILE") - echo "`echo "$item: $NEWTODO"`" + echo "$item: $NEWTODO" echo "TODO: $item prioritized ($newpri)." } cleanup From 821b9d2795a54a74fd2d09e90a10a2b25d7ab909 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 4 Jun 2010 22:22:15 +0800 Subject: [PATCH 2/4] Bugfix: _list() cannot handle filter TERM starting with space. Added proper quoting at check for search term starting with a dash. Added tests for ls use with TERM, both with literal text and regexps. Seems that use case was missing from the tests so far. Extra: Removed unnecessary "$@" argument to for() loop. --- tests/t1300-ls.sh | 41 +++++++++++++++++++++++++++++++++++++++++ todo.sh | 4 ++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/tests/t1300-ls.sh b/tests/t1300-ls.sh index fb47438..a374c5b 100755 --- a/tests/t1300-ls.sh +++ b/tests/t1300-ls.sh @@ -53,6 +53,47 @@ test_todo_session 'checking TODOTXT_FINAL_FILTER' <>> todo.sh ls second +3 bbb yyy this line should be second. +-- +TODO: 1 of 3 tasks shown + +>>> todo.sh ls "should be f" +2 aaa zzz this line should be first. +-- +TODO: 1 of 3 tasks shown + +>>> todo.sh ls " zzz" +2 aaa zzz this line should be first. +-- +TODO: 1 of 3 tasks shown +EOF + +# +# check the filtering of TERM with regexp +# +test_todo_session 'checking filtering of TERM with regexp' <>> todo.sh ls "ir[ds]" +2 aaa zzz this line should be first. +1 ccc xxx this line should be third. +-- +TODO: 2 of 3 tasks shown + +>>> todo.sh ls "f.*t" +2 aaa zzz this line should be first. +-- +TODO: 1 of 3 tasks shown + +>>> todo.sh ls "ir[ds]" xxx +1 ccc xxx this line should be third. +-- +TODO: 1 of 3 tasks shown +EOF + # # check the x command line option # diff --git a/todo.sh b/todo.sh index f8c4c5e..b82c234 100755 --- a/todo.sh +++ b/todo.sh @@ -515,10 +515,10 @@ _list() { ## Prefix the filter_command with the pre_filter_command filter_command="${pre_filter_command:-}" - for search_term in "$@" + for search_term do ## See if the first character of $search_term is a dash - if [ ${search_term:0:1} != '-' ] + if [ "${search_term:0:1}" != '-' ] then ## First character isn't a dash: hide lines that don't match ## this $search_term From 9f03cf68471b9884d1f26a2f20511f9e6c155e20 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 4 Jun 2010 22:50:09 +0800 Subject: [PATCH 3/4] Made verbose message of _addto() consistent with other task messages. In verbose mode, commands first print the updated task, then summarize the change in the following line. The add/addm/addto commands deviated from this, using "TODO: '' added on line N." This change splits this into two separate lines, obsoletes the implementation jargon of "line", and makes it easier to visually parse the message. This is also a preparation for a possible future use of a _list()-like function, so that the updated task is processed and highlighted like the normal task output. --- tests/t1000-addlist.sh | 12 ++++++++---- tests/t1010-add-date.sh | 12 ++++++++---- tests/t1020-addtolistfile.sh | 12 ++++++++---- tests/t1030-addto-date.sh | 12 ++++++++---- tests/t1200-pri.sh | 3 ++- tests/t2000-multiline.sh | 12 ++++++++---- tests/t9999-testsuite_example.sh | 9 ++++++--- todo.sh | 3 ++- 8 files changed, 50 insertions(+), 25 deletions(-) diff --git a/tests/t1000-addlist.sh b/tests/t1000-addlist.sh index f881f8b..42e16e8 100755 --- a/tests/t1000-addlist.sh +++ b/tests/t1000-addlist.sh @@ -12,7 +12,8 @@ command work, including support for filtering. # test_todo_session 'basic add/list' <>> todo.sh add notice the daisies -TODO: 'notice the daisies' added on line 1. +1: notice the daisies +TODO: 1 added. >>> todo.sh list 1 notice the daisies @@ -20,7 +21,8 @@ TODO: 'notice the daisies' added on line 1. TODO: 1 of 1 tasks shown >>> todo.sh add smell the roses -TODO: 'smell the roses' added on line 2. +2: smell the roses +TODO: 2 added. >>> todo.sh list 1 notice the daisies @@ -46,7 +48,8 @@ EOF test_todo_session 'case-insensitive filtering' <>> todo.sh add smell the uppercase Roses -TODO: 'smell the uppercase Roses' added on line 3. +3: smell the uppercase Roses +TODO: 3 added. >>> todo.sh list roses 2 smell the roses @@ -57,7 +60,8 @@ EOF test_todo_session 'add with &' <>> todo.sh add "dig the garden & water the flowers" -TODO: 'dig the garden & water the flowers' added on line 4. +4: dig the garden & water the flowers +TODO: 4 added. >>> todo.sh list 4 dig the garden & water the flowers diff --git a/tests/t1010-add-date.sh b/tests/t1010-add-date.sh index 50629ca..603d199 100755 --- a/tests/t1010-add-date.sh +++ b/tests/t1010-add-date.sh @@ -12,7 +12,8 @@ a date to each item. # test_todo_session 'cmd line first day' <>> todo.sh -t add notice the daisies -TODO: '2009-02-13 notice the daisies' added on line 1. +1: 2009-02-13 notice the daisies +TODO: 1 added. >>> todo.sh list 1 2009-02-13 notice the daisies @@ -24,7 +25,8 @@ test_tick test_todo_session 'cmd line second day' <>> todo.sh -t add smell the roses -TODO: '2009-02-14 smell the roses' added on line 2. +2: 2009-02-14 smell the roses +TODO: 2 added. >>> todo.sh list 1 2009-02-13 notice the daisies @@ -37,7 +39,8 @@ test_tick test_todo_session 'cmd line third day' <>> todo.sh -t add mow the lawn -TODO: '2009-02-15 mow the lawn' added on line 3. +3: 2009-02-15 mow the lawn +TODO: 3 added. >>> todo.sh list 1 2009-02-13 notice the daisies @@ -55,7 +58,8 @@ test_tick 3600 test_todo_session 'config file third day' <>> todo.sh add take out the trash -TODO: '2009-02-15 take out the trash' added on line 4. +4: 2009-02-15 take out the trash +TODO: 4 added. >>> todo.sh list 1 2009-02-13 notice the daisies diff --git a/tests/t1020-addtolistfile.sh b/tests/t1020-addtolistfile.sh index 760a8f5..575fb16 100755 --- a/tests/t1020-addtolistfile.sh +++ b/tests/t1020-addtolistfile.sh @@ -19,7 +19,8 @@ touch "$HOME/garden.txt" test_todo_session 'basic addto/listfile' <>> todo.sh addto garden.txt notice the daisies -GARDEN: 'notice the daisies' added on line 1. +1: notice the daisies +GARDEN: 1 added. >>> todo.sh listfile garden.txt 1 notice the daisies @@ -27,7 +28,8 @@ GARDEN: 'notice the daisies' added on line 1. GARDEN: 1 of 1 tasks shown >>> todo.sh addto garden.txt smell the roses -GARDEN: 'smell the roses' added on line 2. +2: smell the roses +GARDEN: 2 added. >>> todo.sh listfile garden.txt 1 notice the daisies @@ -53,7 +55,8 @@ EOF test_todo_session 'case-insensitive filtering' <>> todo.sh addto garden.txt smell the uppercase Roses -GARDEN: 'smell the uppercase Roses' added on line 3. +3: smell the uppercase Roses +GARDEN: 3 added. >>> todo.sh listfile garden.txt roses 2 smell the roses @@ -64,7 +67,8 @@ EOF test_todo_session 'addto with &' <>> todo.sh addto garden.txt "dig the garden & water the flowers" -GARDEN: 'dig the garden & water the flowers' added on line 4. +4: dig the garden & water the flowers +GARDEN: 4 added. >>> todo.sh listfile garden.txt 4 dig the garden & water the flowers diff --git a/tests/t1030-addto-date.sh b/tests/t1030-addto-date.sh index 8f05aa4..899794d 100755 --- a/tests/t1030-addto-date.sh +++ b/tests/t1030-addto-date.sh @@ -14,7 +14,8 @@ touch "$HOME/garden.txt" # test_todo_session 'cmd line first day' <>> todo.sh -t addto garden.txt notice the daisies -GARDEN: '2009-02-13 notice the daisies' added on line 1. +1: 2009-02-13 notice the daisies +GARDEN: 1 added. >>> todo.sh listfile garden.txt 1 2009-02-13 notice the daisies @@ -26,7 +27,8 @@ test_tick test_todo_session 'cmd line second day' <>> todo.sh -t addto garden.txt smell the roses -GARDEN: '2009-02-14 smell the roses' added on line 2. +2: 2009-02-14 smell the roses +GARDEN: 2 added. >>> todo.sh listfile garden.txt 1 2009-02-13 notice the daisies @@ -39,7 +41,8 @@ test_tick test_todo_session 'cmd line third day' <>> todo.sh -t addto garden.txt mow the lawn -GARDEN: '2009-02-15 mow the lawn' added on line 3. +3: 2009-02-15 mow the lawn +GARDEN: 3 added. >>> todo.sh listfile garden.txt 1 2009-02-13 notice the daisies @@ -57,7 +60,8 @@ test_tick 3600 test_todo_session 'config file third day' <>> todo.sh addto garden.txt take out the trash -GARDEN: '2009-02-15 take out the trash' added on line 4. +4: 2009-02-15 take out the trash +GARDEN: 4 added. >>> todo.sh listfile garden.txt 1 2009-02-13 notice the daisies diff --git a/tests/t1200-pri.sh b/tests/t1200-pri.sh index 4326470..b8742e2 100755 --- a/tests/t1200-pri.sh +++ b/tests/t1200-pri.sh @@ -75,7 +75,8 @@ TODO: 2 prioritized (A). TODO: 2 of 3 tasks shown >>> todo.sh add "smell the coffee +wakeup" -TODO: 'smell the coffee +wakeup' added on line 4. +4: smell the coffee +wakeup +TODO: 4 added. >>> todo.sh -p list 2 (A) notice the sunflowers diff --git a/tests/t2000-multiline.sh b/tests/t2000-multiline.sh index 43ab362..3eaf742 100755 --- a/tests/t2000-multiline.sh +++ b/tests/t2000-multiline.sh @@ -33,7 +33,8 @@ fi ## Add test # Create the expected file -echo "TODO: 'eat apples eat oranges drink milk' added on line 2.">$HOME/expect.multi +echo "2: eat apples eat oranges drink milk +TODO: 2 added.">$HOME/expect.multi test_expect_success 'multiline squash item add' ' ( @@ -108,9 +109,12 @@ fi ## Multiple line addition # Create the expected file -echo "TODO: 'eat apples' added on line 2." > $HOME/expect.multi -echo "TODO: 'eat oranges' added on line 3." >>$HOME/expect.multi -echo "TODO: 'drink milk' added on line 4." >> $HOME/expect.multi +echo "2: eat apples +TODO: 2 added." > $HOME/expect.multi +echo "3: eat oranges +TODO: 3 added." >>$HOME/expect.multi +echo "4: drink milk +TODO: 4 added." >> $HOME/expect.multi test_expect_success 'actual multiline add' ' ( diff --git a/tests/t9999-testsuite_example.sh b/tests/t9999-testsuite_example.sh index 13d6fcc..64994e3 100755 --- a/tests/t9999-testsuite_example.sh +++ b/tests/t9999-testsuite_example.sh @@ -48,7 +48,8 @@ TODO: 2 marked as done. TODO: 4 of 4 tasks shown >>> todo.sh add "make the coffee +wakeup" -TODO: 'make the coffee +wakeup' added on line 5. +5: make the coffee +wakeup +TODO: 5 added. >>> todo.sh -p list coffee 5 make the coffee +wakeup @@ -57,7 +58,8 @@ TODO: 'make the coffee +wakeup' added on line 5. TODO: 2 of 5 tasks shown >>> todo.sh add "visit http://example.com" -TODO: 'visit http://example.com' added on line 6. +6: visit http://example.com +TODO: 6 added. >>> todo.sh -p list 1 (B) smell the uppercase Roses +flowers @outside @@ -134,7 +136,8 @@ TODO: 5 of 5 tasks shown TODO: 5 of 5 tasks shown >>> todo.sh add "the coffee +wakeup" -TODO: 'the coffee +wakeup' added on line 6. +6: the coffee +wakeup +TODO: 6 added. >>> todo.sh -p list 1 (B) smell the uppercase Roses +flowers @outside diff --git a/todo.sh b/todo.sh index b82c234..fc1fd16 100755 --- a/todo.sh +++ b/todo.sh @@ -484,7 +484,8 @@ _addto() { TASKNUM=$(sed -n '$ =' "$file") BASE=$(basename "$file") PREFIX=$(echo ${BASE%%.[^.]*} | tr [a-z] [A-Z]) - echo "${PREFIX}: '$input' added on line $TASKNUM." + echo "$TASKNUM: $input" + echo "${PREFIX}: $TASKNUM added." } } From 8b7e2e6aada05fd824cbb19dcf88e869d27b8282 Mon Sep 17 00:00:00 2001 From: Ed Blackman Date: Wed, 9 Jun 2010 03:31:56 +0800 Subject: [PATCH 4/4] Replace colorization sed scripts with ones that are more compatible with OSX sed and NLS todo items. They're also more consistent with other internal usage of sed. --- todo.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/todo.sh b/todo.sh index fc1fd16..cad4312 100755 --- a/todo.sh +++ b/todo.sh @@ -572,10 +572,10 @@ _list() { | eval ${TODOTXT_SORT_COMMAND} \ | sed ''' /^[0-9]\{'$PADDING'\} x /! { - s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g; - s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g; - s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g; - s/\(.*([D-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g; + /(A)/ s|^.*|'$PRI_A'&'$DEFAULT'| + /(B)/ s|^.*|'$PRI_B'&'$DEFAULT'| + /(C)/ s|^.*|'$PRI_C'&'$DEFAULT'| + /([D-Z])/ s|^.*|'$PRI_X'&'$DEFAULT'| } ''' \ | sed '''