From 687c3b596a36ea5de4e57a34b00b0bff848fe51f Mon Sep 17 00:00:00 2001 From: "Daniel St.Jacques" Date: Sat, 7 Oct 2017 17:23:23 -0400 Subject: [PATCH 1/3] Updated add command to accept lowercase priority --- tests/t1010-add-date.sh | 2 +- todo.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/t1010-add-date.sh b/tests/t1010-add-date.sh index f53080d4..636e3949 100755 --- a/tests/t1010-add-date.sh +++ b/tests/t1010-add-date.sh @@ -22,7 +22,7 @@ TODO: 1 of 1 tasks shown EOF test_todo_session 'cmd line first day with priority' <>> todo.sh -pt add '(A) notice the daisies' +>>> todo.sh -pt add '(a) notice the daisies' 2 (A) 2009-02-13 notice the daisies TODO: 2 added. diff --git a/todo.sh b/todo.sh index 10bf9cc3..35fc97d9 100755 --- a/todo.sh +++ b/todo.sh @@ -465,6 +465,20 @@ replaceOrPrepend() fi } +uppercasePriority() +{ + # Precondition: $input contains task text for which to uppercase priority. + # Postcondition: Modifies $input. + + lower=( {a..z} ) + upper=( {A..Z} ) + for ((i=0; i<26; i++)) + do + upperPriority="${upperPriority};s/^[(]${lower[i]}[)]/(${upper[i]})/" + done + input=$(echo $input | sed $upperPriority) +} + #Preserving environment variables so they don't get clobbered by the config file OVR_TODOTXT_AUTO_ARCHIVE="$TODOTXT_AUTO_ARCHIVE" OVR_TODOTXT_FORCE="$TODOTXT_FORCE" @@ -773,6 +787,7 @@ _addto() { file="$1" input="$2" cleaninput + uppercasePriority if [[ $TODOTXT_DATE_ON_ADD = 1 ]]; then now=$(date '+%Y-%m-%d') From 8e54bf9ca8da263d5c51d223a621ffeb70232372 Mon Sep 17 00:00:00 2001 From: "Daniel St.Jacques" Date: Sat, 7 Oct 2017 18:45:35 -0400 Subject: [PATCH 2/3] Fixed handling of spaces in quoted strings when uppercasing --- todo.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/todo.sh b/todo.sh index 35fc97d9..10ea6140 100755 --- a/todo.sh +++ b/todo.sh @@ -469,14 +469,13 @@ uppercasePriority() { # Precondition: $input contains task text for which to uppercase priority. # Postcondition: Modifies $input. - lower=( {a..z} ) upper=( {A..Z} ) for ((i=0; i<26; i++)) do upperPriority="${upperPriority};s/^[(]${lower[i]}[)]/(${upper[i]})/" done - input=$(echo $input | sed $upperPriority) + input=$(echo "$input" | sed $upperPriority) } #Preserving environment variables so they don't get clobbered by the config file From ab0b20e42a0abfd480cf5eef90d1d12984e1c8ae Mon Sep 17 00:00:00 2001 From: "Daniel St.Jacques" Date: Mon, 9 Oct 2017 20:54:38 -0400 Subject: [PATCH 3/3] Added testcase for add with lowercase priority --- tests/t1010-add-date.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/t1010-add-date.sh b/tests/t1010-add-date.sh index 636e3949..74f5917d 100755 --- a/tests/t1010-add-date.sh +++ b/tests/t1010-add-date.sh @@ -22,7 +22,7 @@ TODO: 1 of 1 tasks shown EOF test_todo_session 'cmd line first day with priority' <>> todo.sh -pt add '(a) notice the daisies' +>>> todo.sh -pt add '(A) notice the daisies' 2 (A) 2009-02-13 notice the daisies TODO: 2 added. @@ -37,6 +37,22 @@ TODO: 2 of 2 tasks shown TODO: 2 deleted. EOF +test_todo_session 'cmd line first day with lowercase priority' <>> todo.sh -pt add '(b) notice the daisies' +2 (B) 2009-02-13 notice the daisies +TODO: 2 added. + +>>> todo.sh -p list +2 (B) 2009-02-13 notice the daisies +1 2009-02-13 notice the daisies +-- +TODO: 2 of 2 tasks shown + +>>> todo.sh -npf del 2 +2 (B) 2009-02-13 notice the daisies +TODO: 2 deleted. +EOF + test_tick test_todo_session 'cmd line second day' <