From 2891472630050403d95275a2aaaf3b4653d09e6c Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Sat, 9 Jul 2011 16:46:51 +0200 Subject: [PATCH] Add test to enforce use of $(...) code style in todo.sh. Pull request #26 by trajano (e24777fa2cf40d2a50b2) changed `...` to $(...), but the following commit 7900ad7e1b71bee1b828 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 #46 --- tests/t0100-code-nobacktick.sh | 15 +++++++++++++++ todo.sh | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 tests/t0100-code-nobacktick.sh diff --git a/tests/t0100-code-nobacktick.sh b/tests/t0100-code-nobacktick.sh new file mode 100755 index 0000000..6db16d6 --- /dev/null +++ b/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' <>> sed -n -e 's/[ \t]#.*//' -e '/\d96/{=;p}' "$(which todo.sh)" +EOF + +test_done diff --git a/todo.sh b/todo.sh index 0d7762a..54f2071 100755 --- a/todo.sh +++ b/todo.sh @@ -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