Skip to content

Commit

Permalink
Add test to enforce use of $(...) code style in todo.sh.
Browse files Browse the repository at this point in the history
Pull request todotxt#26 by trajano (e24777f) changed `...` to $(...), but the following commit 7900ad7 already 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 todotxt#46
  • Loading branch information
inkarkat authored and ginatrapani committed Jul 9, 2011
1 parent f3af778 commit 2891472
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions tests/t0100-code-nobacktick.sh
@@ -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 changes: 1 addition & 1 deletion todo.sh
Expand Up @@ -621,7 +621,7 @@ _addto() {

if [[ $TODOTXT_DATE_ON_ADD = 1 ]]; then
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
echo "$input" >> "$file"
if [ $TODOTXT_VERBOSE -gt 0 ]; then
Expand Down

0 comments on commit 2891472

Please sign in to comment.