Add test to enforce use of $(...) code style in todo.sh.
Pull request #26 by trajano (e24777fa2c) changed `...` to $(...), but the following commit7900ad7e1balready added another old-style one. I think the tests can also be used for some simple enforcement of coding style, so here is a first shot at it. Closes #46
This commit is contained in:
committed by
Gina Trapani
parent
f3af778d3e
commit
2891472630
15
tests/t0100-code-nobacktick.sh
Executable file
15
tests/t0100-code-nobacktick.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
test_description='no old-style backtick command substitution
|
||||||
|
|
||||||
|
This test checks the todo.sh script itself for occurrences
|
||||||
|
of old-style backtick command substitution, which should be
|
||||||
|
replaced with $(...).
|
||||||
|
'
|
||||||
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
test_todo_session 'no old-style backtick command substitution' <<EOF
|
||||||
|
>>> sed -n -e 's/[ \t]#.*//' -e '/\d96/{=;p}' "$(which todo.sh)"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_done
|
||||||
2
todo.sh
2
todo.sh
@@ -621,7 +621,7 @@ _addto() {
|
|||||||
|
|
||||||
if [[ $TODOTXT_DATE_ON_ADD = 1 ]]; then
|
if [[ $TODOTXT_DATE_ON_ADD = 1 ]]; then
|
||||||
now=$(date '+%Y-%m-%d')
|
now=$(date '+%Y-%m-%d')
|
||||||
input=`echo "$input" | sed -e 's/^\(([A-Z]) \)\{0,1\}/\1'"$now /"`
|
input=$(echo "$input" | sed -e 's/^\(([A-Z]) \)\{0,1\}/\1'"$now /")
|
||||||
fi
|
fi
|
||||||
echo "$input" >> "$file"
|
echo "$input" >> "$file"
|
||||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user