From 69e756a2cde9b5eb5044fdfbda8ddceb63b2120d Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 4 Jun 2010 16:22:15 +0200 Subject: [PATCH] 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