From 783263ebb9d6028e56fb5754a0bce80ad57cfbf9 Mon Sep 17 00:00:00 2001 From: chrysle Date: Sat, 21 Jan 2023 12:31:40 +0100 Subject: [PATCH 1/2] Added status messages for listaddons and file test --- tests/t8010-listaddons.sh | 1 + todo.sh | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/t8010-listaddons.sh b/tests/t8010-listaddons.sh index b4e89aa9..aa62f2ce 100755 --- a/tests/t8010-listaddons.sh +++ b/tests/t8010-listaddons.sh @@ -9,6 +9,7 @@ This test checks listing of custom actions. test_todo_session 'no custom actions' <>> todo.sh listaddons +TODO: '$TODO_ACTIONS_DIR' does not exist. EOF make_action "foo" diff --git a/todo.sh b/todo.sh index fb8d4bce..1dc6d1e1 100755 --- a/todo.sh +++ b/todo.sh @@ -864,7 +864,7 @@ _list() { local FILE="$1" ## If the file starts with a "/" use absolute path. Otherwise, ## try to find it in either $TODO_DIR or using a relative path - if [ "${1:0:1}" == / ]; then + if [ "${1:0:1}" == / ] && [ -f "$FILE" ]; then ## Absolute path src="$FILE" elif [ -f "$TODO_DIR/$FILE" ]; then @@ -1485,14 +1485,22 @@ note: PRIORITY must be anywhere from A to Z." "listaddons" ) if [ -d "$TODO_ACTIONS_DIR" ]; then cd "$TODO_ACTIONS_DIR" || exit $? + VALID=0 for action in * do if [ -f "$action" ] && [ -x "$action" ]; then echo "$action" + VALID+=1 elif [ -d "$action" ] && [ -x "$action/$action" ]; then echo "$action" + VALID+=1 fi done + if ! [ "$VALID" -gt 0 ]; then + echo "TODO: '$TODO_ACTIONS_DIR' does not contain valid actions." + fi + else + [ "$TODOTXT_VERBOSE" -gt 0 ] && echo "TODO: '$TODO_ACTIONS_DIR' does not exist." fi ;; From a66c6b0bb35eb0022db6fa0e8d8f93e0f4495f5e Mon Sep 17 00:00:00 2001 From: chrysle Date: Sun, 22 Jan 2023 17:37:37 +0100 Subject: [PATCH 2/2] Fixed completions break and prettified code --- tests/t8010-listaddons.sh | 11 +++++++++++ todo.sh | 20 +++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/tests/t8010-listaddons.sh b/tests/t8010-listaddons.sh index aa62f2ce..779dafa0 100755 --- a/tests/t8010-listaddons.sh +++ b/tests/t8010-listaddons.sh @@ -10,12 +10,15 @@ This test checks listing of custom actions. test_todo_session 'no custom actions' <>> todo.sh listaddons TODO: '$TODO_ACTIONS_DIR' does not exist. +=== 1 EOF make_action "foo" test_todo_session 'one custom action' <>> todo.sh listaddons foo +-- +TODO: 1 valid addon actions found. EOF make_action "bar" @@ -27,6 +30,8 @@ bar foo ls quux +-- +TODO: 4 valid addon actions found. EOF chmod -x .todo.actions.d/foo @@ -40,6 +45,8 @@ test_todo_session 'nonexecutable action' <&2 "$*" exit 1 } @@ -1485,22 +1486,27 @@ note: PRIORITY must be anywhere from A to Z." "listaddons" ) if [ -d "$TODO_ACTIONS_DIR" ]; then cd "$TODO_ACTIONS_DIR" || exit $? - VALID=0 + actionsCnt=0 for action in * do if [ -f "$action" ] && [ -x "$action" ]; then echo "$action" - VALID+=1 + ((actionsCnt+=1)) elif [ -d "$action" ] && [ -x "$action/$action" ]; then echo "$action" - VALID+=1 + ((actionsCnt+=1)) fi done - if ! [ "$VALID" -gt 0 ]; then - echo "TODO: '$TODO_ACTIONS_DIR' does not contain valid actions." + if ! [ "$actionsCnt" -gt 0 ]; then + die "TODO: '$TODO_ACTIONS_DIR' does not contain valid actions." + else + if [ "$TODOTXT_VERBOSE" -gt 0 ]; then + echo "--" + echo "TODO: $actionsCnt valid addon actions found." + fi fi else - [ "$TODOTXT_VERBOSE" -gt 0 ] && echo "TODO: '$TODO_ACTIONS_DIR' does not exist." + die "TODO: '$TODO_ACTIONS_DIR' does not exist." fi ;;