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:
33
tests/t1340-listescapes.sh
Executable file
33
tests/t1340-listescapes.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
|
||||
test_description='list with escape sequences
|
||||
|
||||
This test checks listing of tasks that have embedded escape sequences in them.
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
#
|
||||
# check aborted list output on \c escape sequence
|
||||
#
|
||||
cat > todo.txt <<'EOF'
|
||||
first todo
|
||||
second todo run C:\WINDOWS\sysnative\cscript.exe
|
||||
third todo
|
||||
EOF
|
||||
|
||||
test_todo_session 'aborted list output on backslash-c' <<'EOF'
|
||||
>>> todo.sh ls
|
||||
1 first todo
|
||||
2 second todo run C:\\\\WINDOWS\\\\sysnative\\\\cscript.exe
|
||||
3 third todo
|
||||
--
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh ls 2
|
||||
2 second todo run C:\\\\WINDOWS\\\\sysnative\\\\cscript.exe
|
||||
--
|
||||
TODO: 1 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
test_done
|
||||
22
todo.sh
22
todo.sh
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user