From 6be78ca5fafe971d98cd100fef8e71402b33378c Mon Sep 17 00:00:00 2001 From: "David A. Harding" Date: Fri, 13 Mar 2009 22:21:48 -0400 Subject: [PATCH] Added Exclusion Syntax by Jacobo de Vera -keyword or -"key phrase" should exclude those terms from the output. --- todo.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/todo.sh b/todo.sh index b9298f0..a38e713 100755 --- a/todo.sh +++ b/todo.sh @@ -363,16 +363,31 @@ _list() { ## Get our search arguments, if any shift ## was file name, new $1 is first search term - filter_command="${prefilter_command:-}" + ## Prefix the filter_command with the pre_filter_command + filter_command="${pre_filter_command:-}" for search_term in "$@" do - filter_command="${filter_command:-} ${filter_command:+|} \ - grep -i \"$search_term\" " + ## See if the first character of $search_term is a dash + if [ ${search_term:0:1} != '-' ] + then + ## First character isn't a dash: hide lines that don't match + ## this $search_term + filter_command="${filter_command:-} ${filter_command:+|} \ + grep -i \"$search_term\" " + else + ## First character is a dash: hide lines that match this + ## $search_term + # + ## Remove the first character (-) before adding to our filter command + filter_command="${filter_command:-} ${filter_command:+|} \ + grep -v -i \"${search_term:1}\" " + fi done - [ -n "$postfilter_command" ] && { - filter_command="${filter_command:-}${filter_command:+ | }${postfilter_command:-}" + ## If post_filter_command is set, append it to the filter_command + [ -n "$post_hilter_command" ] && { + filter_command="${filter_command:-}${filter_command:+ | }${post_filter_command:-}" } ## Figure out how much padding we need to use