Minor fixes identified through shellcheck and other tools (#350)

* fix whitespace

* fix spelling

* fix whitespace

* unify headers of tests

* fix some issues in tests, identified by shellcheck

* fix bash completions

bash completion files are not supposed to be executable

* fix some issues identified by shellcheck

Co-authored-by: Ali Karbassi <ali@karbassi.com>
This commit is contained in:
a1346054
2021-08-09 20:03:49 +00:00
committed by GitHub
parent ee94a3fac5
commit 2d70a0aadf
40 changed files with 88 additions and 119 deletions

View File

@@ -147,7 +147,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- Changed odd tabs to spaces.
- Faster help/useage document outputs.
- Faster help/usage document outputs.
- Consolidated `TODOTXT_VERBOSE` tests.
- Refactored various add functionality to one function.
- Updated `_list()` output to match updated `addto`.
@@ -436,7 +436,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- `list` is case insenstive. ie, `todo list Mac` will match lines with "mac" and "Mac"
- `list` is case insensitive. ie, `todo list Mac` will match lines with "mac" and "Mac"
### Changed

View File

@@ -34,5 +34,3 @@ test "$VN" = "$VC" || {
echo >&2 "VERSION=$VN"
echo "VERSION=$VN" >$VF
}

View File

@@ -85,7 +85,7 @@ See [CHANGELOG.md][CHANGELOG]
## Contributing
We welcome all contributations. First read our [Contributor Code of Conduct][CODE_OF_CONDUCT] and then get started [contributing][CONTRIBUTING].
We welcome all contributions. First read our [Contributor Code of Conduct][CODE_OF_CONDUCT] and then get started [contributing][CONTRIBUTING].
## License
@@ -94,7 +94,7 @@ GNU General Public License v3.0 © [todo.txt org][github]
[release]: https://github.com/todotxt/todo.txt-cli/releases
[website]: http://todotxt.org
[website]: http://todotxt.org/
[github]: https://github.com/todotxt
[USAGE]: ./USAGE.md
[CHANGELOG]: ./CHANGELOG.md

View File

@@ -104,7 +104,7 @@ todo.sh help [ACTION...]
Displays all tasks that contain TERM(s) sorted by priority with line numbers. Each task must match all TERM(s) (logical AND); to display tasks that contain any TERM (logical OR), use `"TERM1\|TERM2\|..."` (with quotes), or `TERM1\\|TERM2` (unquoted). Hides all tasks that contain TERM(s) preceded by a minus sign (i.e. `-TERM`).
If no TERM specified, lists entire todo.txt.
```shell
todo.sh list [TERM...]
todo.sh ls [TERM...]

View File

@@ -266,7 +266,7 @@ and the dates and timestamps will be artificially fixed.
Then the session can be used to make a unit test thanks to
test_todo_session, see the existing tests as examples.
Be careful to replace all occurences of the full path to the test
Be careful to replace all occurrences of the full path to the test
directory by $HOME as testshell.sh will explain you when you execute it
otherwise the tests will work properly only on your own computer.

View File

@@ -21,7 +21,7 @@ make_action_in_folder()
{
unset TODO_ACTIONS_DIR
[ -d .todo.actions.d ] || mkdir .todo.actions.d
mkdir .todo.actions.d/$1
mkdir ".todo.actions.d/$1"
cat > ".todo.actions.d/$1/$1" <<EOF
#!/bin/bash
[ "\$1" = "usage" ] && {

View File

@@ -67,15 +67,15 @@ do
'')
continue ;;
fixed)
fixed=$(($fixed + $value)) ;;
fixed=$((fixed + $value)) ;;
success)
success=$(($success + $value)) ;;
success=$((success + $value)) ;;
failed)
failed=$(($failed + $value)) ;;
failed=$((failed + $value)) ;;
broken)
broken=$(($broken + $value)) ;;
broken=$((broken + $value)) ;;
total)
total=$(($total + $value)) ;;
total=$((total + $value)) ;;
esac
done <"$file"
done

View File

@@ -59,7 +59,6 @@ test_expect_success 'null list filter' '
todo.sh listall filter > output && test_cmp expect output
'
#
# lsc|listcon
#

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='list functionality
@@ -162,7 +161,6 @@ TODO: 1 of 5 tasks shown
TODO: 1 of 5 tasks shown
EOF
#
# check the x command line option
#

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='listcon functionality

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='listproj functionality
@@ -117,7 +116,6 @@ test_todo_session 'listproj with context special cases' <<EOF
+sunflowers
EOF
cat > todo.txt <<EOF
+prj01 -- Some project 1 task
EOF

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='list highlighting

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='list with escape sequences

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='highlighting projects and contexts

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='highlighting date, item numbers and metadata
@@ -32,7 +31,6 @@ test_todo_session 'highlighting for date, item numbers and metadata' <<'EOF'
TODO: 3 of 3 tasks shown
EOF
test_todo_session 'suppressing highlighting for date, item numbers and metadata' <<'EOF'
>>> todo.sh -p -d "$TEST_TODO_LABEL_COLORS" ls
1 2018-11-11 task with date

View File

@@ -83,4 +83,5 @@ TODO: 3 marked as done.
>>> todo.sh -a do 3
TODO: 3 is already marked done.
EOF
test_done

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='basic move functionality
'

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='help functionality

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='shorthelp functionality
@@ -36,7 +35,6 @@ test_todo_session 'shorthelp output with custom action' <<EOF
See "help" for more details.
EOF
# Verify that custom configuration is actually processed (when the -d option
# precedes the -h option) by specifying a different actions directory and moving
# our custom action there. The help output should mention the "Add-On Actions".

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='todo.sh configuration with a sole todo.txt data file.

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='Bash completion functionality

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='Bash context completion functionality

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='Bash project completion functionality

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='Bash task number completion functionality

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='Bash todo file completion functionality

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='Bash add-on action completion functionality

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='Bash add-on action file completion functionality

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='Bash completion with different path functionality
@@ -28,8 +27,6 @@ _todo2()
test_todo_custom_completion _todo2 'all todo2 contexts' 'todo2 list @' '@garden @outdoor @outside'
# Remove the test environment's bin directory from the PATH, so that our test
# executable must be launched with an explicit path.
PATH=${PATH##"${PWD}/bin:"}

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='Bash completion with different aliases functionality
@@ -46,7 +45,6 @@ test_todo_session 'todo 1 and 2 contexts' <<EOF
@oriental
EOF
# Define a second completion function that injects the different configuration
# file. In real use, this would be installed via
# complete -F _todo2 todo2

View File

@@ -1,5 +1,4 @@
#!/bin/bash
#
test_description='Bash help completion functionality

View File

@@ -172,12 +172,12 @@ test_set_editor () {
# the text_expect_* functions instead.
test_ok_ () {
test_success=$(($test_success + 1))
test_success=$((test_success + 1))
say_color "" " ok $test_count: $@"
}
test_failure_ () {
test_failure=$(($test_failure + 1))
test_failure=$((test_failure + 1))
say_color error "FAIL $test_count: $1"
shift
echo "$@"
@@ -185,12 +185,12 @@ test_failure_ () {
}
test_known_broken_ok_ () {
test_fixed=$(($test_fixed+1))
test_fixed=$((test_fixed + 1))
say_color "" " FIXED $test_count: $@"
}
test_known_broken_failure_ () {
test_broken=$(($test_broken+1))
test_broken=$((test_broken + 1))
say_color skip " still broken $test_count: $@"
}
@@ -206,7 +206,7 @@ test_run_ () {
}
test_skip () {
test_count=$(($test_count+1))
test_count=$((test_count + 1))
to_skip=
for skp in $SKIP_TESTS
do
@@ -364,7 +364,7 @@ test_external_without_stderr () {
test_ok_ "$descr"
else
if [ "$verbose" = t ]; then
output=`echo; echo Stderr is:; cat "$stderr"`
output=$(echo; echo Stderr is:; cat "$stderr")
else
output=
fi
@@ -428,7 +428,7 @@ test_done () {
if test "$test_broken" != 0
then
say_color error "still have $test_broken known breakage(s)"
msg="remaining $(($test_count-$test_broken)) test(s)"
msg="remaining $((test_count - test_broken)) test(s)"
else
msg="$test_count test(s)"
fi
@@ -471,7 +471,7 @@ rm -fr "$test" || {
test_init_todo () {
test "$#" = 1 ||
error "bug in the test script: not 1 parameter to test_init_todo"
owd=`pwd`
owd=$(pwd)
root="$1"
mkdir -p "$root"
cd "$root" || error "Cannot setup todo dir in $root"
@@ -548,7 +548,7 @@ test_init_todo () {
# Usage: test_tick [increment]
test_tick () {
TODO_TEST_TIME=$(($TODO_TEST_TIME + ${1:-86400}))
TODO_TEST_TIME=$((TODO_TEST_TIME + ${1:-86400}))
}
# Generate and run a series of tests based on a transcript.
@@ -581,14 +581,14 @@ test_todo_session () {
status=${line#=== }
;;
"")
if [ ! -z "$cmd" ]; then
if [ $status = 0 ]; then
if [ -n "$cmd" ]; then
if [ "$status" = 0 ]; then
test_expect_output "$1 $subnum" "$cmd"
else
test_expect_code_and_output "$status" "$1 $subnum" "$cmd"
fi
subnum=$(($subnum + 1))
subnum=$((subnum + 1))
cmd=""
status=0
> expect
@@ -602,8 +602,8 @@ test_todo_session () {
;;
esac
done
if [ ! -z "$cmd" ]; then
if [ $status = 0 ]; then
if [ -n "$cmd" ]; then
if [ "$status" = 0 ]; then
test_expect_output "$1 $subnum" "$cmd"
else
test_expect_code_and_output "$status" "$1 $subnum" "$cmd"
@@ -645,7 +645,7 @@ test_todo_custom_completion () {
SAVEIFS=$IFS
IFS=' ' set -- $2
COMP_WORDS=("$@")
COMP_CWORD=$(($# - $offset))
COMP_CWORD=$(($# - offset))
IFS=' ' eval "set -- $expected"
EXPECT=("$@")

View File

@@ -134,7 +134,6 @@ $indentedJoinedConfigFileLocations
-x
Disables TODOTXT_FINAL_FILTER
EndOptionsHelp
[ "$TODOTXT_VERBOSE" -gt 1 ] && cat <<-'EndVerboseHelp'
@@ -156,7 +155,6 @@ $indentedJoinedConfigFileLocations
TODOTXT_SIGIL_VALID_PATTERN=.* tweak the allowed chars for +p and @c
TODOTXT_SIGIL_AFTER_PATTERN="" optionally allow chars after +p / @c
EndVerboseHelp
actionsHelp
addonHelp
@@ -710,7 +708,6 @@ do
fi
done
if [ -z "$TODO_ACTIONS_DIR" ] || [ ! -d "$TODO_ACTIONS_DIR" ]
then
TODO_ACTIONS_DIR="$HOME/.todo/actions"
@@ -788,7 +785,7 @@ ACTION=${1:-$TODOTXT_DEFAULT_ACTION}
if [ $TODOTXT_PLAIN = 1 ]; then
for clr in ${!PRI_@}; do
export "$clr"=$NONE
export "$clr"="$NONE"
done
PRI_X=$NONE
DEFAULT=$NONE
@@ -1093,7 +1090,7 @@ case $action in
SAVEIFS=$IFS
IFS=$'\n'
# Treat each line seperately
# Treat each line separately
for line in $input ; do
_addto "$TODO_FILE" "$line"
done

View File

@@ -1,5 +1,7 @@
#!/bin/bash source-this-script
[ "$BASH_VERSION" ] || return
# bash completion for todo.txt-cli
# Check for bash
[ -z "$BASH_VERSION" ] && return
_todo()
{
@@ -18,7 +20,7 @@ _todo()
local _todo_sh=${_todo_sh:-todo.sh}
local completions
if [ $COMP_CWORD -eq 1 ]; then
if [ "$COMP_CWORD" -eq 1 ]; then
completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons 2>/dev/null) $OPTS"
elif [[ $COMP_CWORD -gt 2 && ( \
"${COMP_WORDS[COMP_CWORD-2]}" =~ ^($MOVE_COMMAND_PATTERN${_todo_file2_actions:+|${_todo_file2_actions}})$ || \