From f3fc18af6b80797e44903521a994218f98f9c022 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Mon, 23 Jan 2012 11:55:15 +0100 Subject: [PATCH] Optimization: Put grep -v empty task filter inside sed. No need to spawn off another process for this; we can do this inside the sed command that joins the task numbers with the task text. Note: The sed on OS X does not understand the \+ bound, only in the form of + when used with -E. Instead, I chose to fall back to the \{1,\} basic regexp, in the hope that it is very portable, and to avoid introducing extended regexps to the script. --- todo.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/todo.sh b/todo.sh index 337bbea..e042765 100755 --- a/todo.sh +++ b/todo.sh @@ -785,12 +785,12 @@ _list() { fi items=$( sed = "$src" \ - | sed ''' + | sed -e ''' N s/^/ / s/ *\([ 0-9]\{'"$PADDING"',\}\)\n/\1 / - ''' \ - | grep -v "^[ 0-9]\+ *$" + /^[ 0-9]\{1,\} *$/d + ''' ) if [ "${filter_command}" ]; then filtered_items=$(echo -n "$items" | eval "${filter_command}")