BUG: task listing aborted on embedded \c escape sequence

Fixed by removing the -e option that causes the echo command to interpret escape characters. Coloring of done tasks (the only step in the _list pipeline that required this interpretation) has been moved into the AWK pipeline step which is responsible for the priority coloring, and which does the escape character interpretation internally.
As a nice side effect, this shortening of the _list pipeline should also speed up the listing a wee bit.
This commit is contained in:
Ingo Karkat
2010-10-21 10:11:40 +02:00
parent 194a062c2d
commit 824101defd
2 changed files with 44 additions and 11 deletions

22
todo.sh
View File

@@ -622,12 +622,12 @@ _list() {
| grep -v "^[ 0-9]\+ *$"
)
if [ "${filter_command}" ]; then
filtered_items=$(echo -ne "$items" | eval ${filter_command})
filtered_items=$(echo -n "$items" | eval ${filter_command})
else
filtered_items=$items
fi
filtered_items=$(
echo -ne "$filtered_items" \
echo -n "$filtered_items" \
| sed '''
s/^ /00000/;
s/^ /0000/;
@@ -636,15 +636,15 @@ _list() {
s/^ /0/;
''' \
| eval ${TODOTXT_SORT_COMMAND} \
| sed '''
/^[0-9]\{'$PADDING'\} x /s|^.*|'$COLOR_DONE'&'$DEFAULT'|
''' \
| awk '''{
pos = match($0, /\([A-Z]\)/)
if( pos > 0 && match($0, /^[0-9]+ x /) != 1 ) {
clr=ENVIRON["PRI_" substr($0, pos+1, 1)]
if (match($0, /^[0-9]+ x /)) {
str = ENVIRON["COLOR_DONE"] $0 ENVIRON["DEFAULT"]
gsub(/\\+033/, "\033", str); print str
} else if (pos > 0) {
clr = ENVIRON["PRI_" substr($0, pos+1, 1)]
str = ( clr ? clr : ENVIRON["PRI_X"] ) $0 ENVIRON["DEFAULT"]
gsub( /\\+033/, "\033", str) ; print str
gsub(/\\+033/, "\033", str); print str
} else { print }
}''' \
| sed '''
@@ -654,13 +654,13 @@ _list() {
''' \
| eval ${TODOTXT_FINAL_FILTER} \
)
echo -ne "$filtered_items${filtered_items:+\n}"
[ "$filtered_items" ] && echo "$filtered_items"
if [ $TODOTXT_VERBOSE -gt 0 ]; then
BASE=$(basename "$FILE")
PREFIX=$(echo ${BASE%%.[^.]*} | tr 'a-z' 'A-Z')
NUMTASKS=$( echo -ne "$filtered_items" | sed -n '$ =' )
TOTALTASKS=$( echo -ne "$items" | sed -n '$ =' )
NUMTASKS=$( echo -n "$filtered_items" | sed -n '$ =' )
TOTALTASKS=$( echo -n "$items" | sed -n '$ =' )
echo "--"
echo "${PREFIX}: ${NUMTASKS:-0} of ${TOTALTASKS:-0} tasks shown"