From 3e82f3ca56aa20c0dc593f613c167e12b331be51 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Sun, 15 Apr 2012 10:33:51 +0200 Subject: [PATCH 1/3] Tests: Extract backtick_check(). --- tests/t0100-code-nobacktick.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/t0100-code-nobacktick.sh b/tests/t0100-code-nobacktick.sh index 1b827b3..c11f6bc 100755 --- a/tests/t0100-code-nobacktick.sh +++ b/tests/t0100-code-nobacktick.sh @@ -9,8 +9,13 @@ On failure, it will print each offending line number and line. ' . ./test-lib.sh +backtick_check() +{ + sed -n -e 's/\(^\|[ \t]\)#.*//' -e '/`/{' -e '=;p' -e '}' "$@" +} + test_todo_session 'no old-style backtick command substitution' <>> sed -n -e 's/\(^\|[ \t]\)#.*//' -e '/\`/{' -e '=;p' -e '}' "$(which todo.sh)" +>>> backtick_check "$(which todo.sh)" EOF test_done From b21d16878f0ec41e0c5e1841fa2475280ffeb296 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Sun, 15 Apr 2012 10:35:17 +0200 Subject: [PATCH 2/3] Tests: Hard-code location of todo.sh. As todo.sh is placed by test-lib at a fixed place, avoid the lookup through which. --- tests/t0100-code-nobacktick.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/t0100-code-nobacktick.sh b/tests/t0100-code-nobacktick.sh index c11f6bc..2fe6bd8 100755 --- a/tests/t0100-code-nobacktick.sh +++ b/tests/t0100-code-nobacktick.sh @@ -15,7 +15,7 @@ backtick_check() } test_todo_session 'no old-style backtick command substitution' <>> backtick_check "$(which todo.sh)" +>>> backtick_check bin/todo.sh EOF test_done From 3b0309d9bc5b7d6b6b6bec7efab8b4b25280cb1d Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Sun, 15 Apr 2012 10:37:41 +0200 Subject: [PATCH 3/3] Replace backticks in config with $(...) This applies e24777fa2cf40d2a50b27478c841f1381f8f4a22 to todo.cfg, too, and adds a verification to the existing test. Note: Because todo.cfg is preprocessed by test-lib, we use the original config from the working copy, not the copy inside the test fixture. --- tests/t0100-code-nobacktick.sh | 2 ++ todo.cfg | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/t0100-code-nobacktick.sh b/tests/t0100-code-nobacktick.sh index 2fe6bd8..eb42fbc 100755 --- a/tests/t0100-code-nobacktick.sh +++ b/tests/t0100-code-nobacktick.sh @@ -16,6 +16,8 @@ backtick_check() test_todo_session 'no old-style backtick command substitution' <>> backtick_check bin/todo.sh + +>>> backtick_check ../../todo.cfg EOF test_done diff --git a/todo.cfg b/todo.cfg index 8504388..ccad921 100644 --- a/todo.cfg +++ b/todo.cfg @@ -2,7 +2,7 @@ # Your todo.txt directory #export TODO_DIR="/Users/gina/Documents/todo" -export TODO_DIR=`dirname "$0"` +export TODO_DIR=$(dirname "$0") # Your todo/done/report.txt locations export TODO_FILE="$TODO_DIR/todo.txt"