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
- Changed odd tabs to spaces. - Changed odd tabs to spaces.
- Faster help/useage document outputs. - Faster help/usage document outputs.
- Consolidated `TODOTXT_VERBOSE` tests. - Consolidated `TODOTXT_VERBOSE` tests.
- Refactored various add functionality to one function. - Refactored various add functionality to one function.
- Updated `_list()` output to match updated `addto`. - 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 ### 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 ### Changed

View File

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

View File

@@ -85,7 +85,7 @@ See [CHANGELOG.md][CHANGELOG]
## Contributing ## 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 ## License
@@ -94,7 +94,7 @@ GNU General Public License v3.0 © [todo.txt org][github]
[release]: https://github.com/todotxt/todo.txt-cli/releases [release]: https://github.com/todotxt/todo.txt-cli/releases
[website]: http://todotxt.org [website]: http://todotxt.org/
[github]: https://github.com/todotxt [github]: https://github.com/todotxt
[USAGE]: ./USAGE.md [USAGE]: ./USAGE.md
[CHANGELOG]: ./CHANGELOG.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`). 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. If no TERM specified, lists entire todo.txt.
```shell ```shell
todo.sh list [TERM...] todo.sh list [TERM...]
todo.sh ls [TERM...] todo.sh ls [TERM...]

View File

@@ -42,27 +42,27 @@ You can pass --verbose (or -v), --debug (or -d), and --immediate
appropriately before running "make". appropriately before running "make".
--verbose:: --verbose::
This makes the test more verbose. Specifically, the This makes the test more verbose. Specifically, the
command being run and their output if any are also command being run and their output if any are also
output. output.
--debug:: --debug::
This may help the person who is developing a new test. This may help the person who is developing a new test.
It causes the command defined with test_debug to run. It causes the command defined with test_debug to run.
--immediate:: --immediate::
This causes the test to immediately exit upon the first This causes the test to immediately exit upon the first
failed test. failed test.
--long-tests:: --long-tests::
This causes additional long-running tests to be run (where This causes additional long-running tests to be run (where
available), for more exhaustive testing. available), for more exhaustive testing.
--tee:: --tee::
In addition to printing the test output to the terminal, In addition to printing the test output to the terminal,
write it to files named 't/test-results/$TEST_NAME.out'. write it to files named 't/test-results/$TEST_NAME.out'.
As the names depend on the tests' file names, it is safe to As the names depend on the tests' file names, it is safe to
run the tests with this option in parallel. run the tests with this option in parallel.
Skipping Tests Skipping Tests
-------------- --------------
@@ -97,15 +97,15 @@ Naming Tests
The test files are named as: The test files are named as:
tNNNN-commandname-details.sh tNNNN-commandname-details.sh
where N is a decimal digit. where N is a decimal digit.
First digit tells the family: First digit tells the family:
0 - the absolute basics and global stuff 0 - the absolute basics and global stuff
1 - basic every-day usage 1 - basic every-day usage
2 - add ins 2 - add ins
Second digit tells the particular command we are testing. Second digit tells the particular command we are testing.
@@ -128,15 +128,15 @@ The test script is written as a shell script. It should start
with the standard "#!/bin/bash" with copyright notices, and an with the standard "#!/bin/bash" with copyright notices, and an
assignment to variable 'test_description', like this: assignment to variable 'test_description', like this:
#!/bin/bash #!/bin/bash
# #
# Copyright (c) 2005 Junio C Hamano # Copyright (c) 2005 Junio C Hamano
# #
test_description='xxx test (option --frotz) test_description='xxx test (option --frotz)
This test registers the following structure in the cache This test registers the following structure in the cache
and tries to run git-ls-files with option --frotz.' and tries to run git-ls-files with option --frotz.'
Source 'test-lib.sh' Source 'test-lib.sh'
@@ -145,7 +145,7 @@ Source 'test-lib.sh'
After assigning test_description, the test script should source After assigning test_description, the test script should source
test-lib.sh like this: test-lib.sh like this:
. ./test-lib.sh . ./test-lib.sh
This test harness library does the following things: This test harness library does the following things:
@@ -219,9 +219,9 @@ library for your script to use.
Example: Example:
test_expect_success \ test_expect_success \
'git-write-tree should be able to write an empty tree.' \ 'git-write-tree should be able to write an empty tree.' \
'tree=$(git-write-tree)' 'tree=$(git-write-tree)'
- test_expect_code <code> <message> <script> - test_expect_code <code> <message> <script>
@@ -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 Then the session can be used to make a unit test thanks to
test_todo_session, see the existing tests as examples. 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 directory by $HOME as testshell.sh will explain you when you execute it
otherwise the tests will work properly only on your own computer. 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 unset TODO_ACTIONS_DIR
[ -d .todo.actions.d ] || mkdir .todo.actions.d [ -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 cat > ".todo.actions.d/$1/$1" <<EOF
#!/bin/bash #!/bin/bash
[ "\$1" = "usage" ] && { [ "\$1" = "usage" ] && {

View File

@@ -15,7 +15,7 @@ case "$1" in
esac esac
if test -n "$color"; then if test -n "$color"; then
say_color () { say_color() {
( (
export TERM export TERM
case "$1" in case "$1" in
@@ -67,15 +67,15 @@ do
'') '')
continue ;; continue ;;
fixed) fixed)
fixed=$(($fixed + $value)) ;; fixed=$((fixed + $value)) ;;
success) success)
success=$(($success + $value)) ;; success=$((success + $value)) ;;
failed) failed)
failed=$(($failed + $value)) ;; failed=$((failed + $value)) ;;
broken) broken)
broken=$(($broken + $value)) ;; broken=$((broken + $value)) ;;
total) total)
total=$(($total + $value)) ;; total=$((total + $value)) ;;
esac esac
done <"$file" done <"$file"
done done

View File

@@ -20,12 +20,12 @@ test_expect_success 'no config file' '
' '
# All the below tests will output the usage message. # All the below tests will output the usage message.
cat > expect << EOF cat > expect <<EOF
Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description] Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description]
Try 'todo.sh -h' for more information. Try 'todo.sh -h' for more information.
EOF EOF
cat > test.cfg << EOF cat > test.cfg <<EOF
export TODO_DIR=. export TODO_DIR=.
export TODO_FILE="\$TODO_DIR/todo.txt" export TODO_FILE="\$TODO_DIR/todo.txt"
export DONE_FILE="\$TODO_DIR/done.txt" export DONE_FILE="\$TODO_DIR/done.txt"
@@ -79,7 +79,7 @@ test_expect_success 'config file (env variable)' '
test_cmp expect output && test -f used_config test_cmp expect output && test -f used_config
' '
cat > minimal.cfg << EOF cat > minimal.cfg <<EOF
export TODO_DIR=. export TODO_DIR=.
touch used_config touch used_config
EOF EOF

View File

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

View File

@@ -7,11 +7,11 @@ This test just makes sure that todo.sh can locate custom actions.
. ./test-lib.sh . ./test-lib.sh
# All the below tests will output the custom action message # All the below tests will output the custom action message
cat > expect << EOF cat > expect <<EOF
TODO: foo TODO: foo
EOF EOF
cat > foo << EOF cat > foo <<EOF
echo "TODO: foo" echo "TODO: foo"
EOF EOF
chmod +x foo chmod +x foo

View File

@@ -45,7 +45,7 @@ grow some corn
thrash some hay thrash some hay
chase the chickens chase the chickens
EOF EOF
test_todo_session 'replace error' << EOF test_todo_session 'replace error' <<EOF
>>> todo.sh replace 10 "hej!" >>> todo.sh replace 10 "hej!"
=== 1 === 1
TODO: No task 10. TODO: No task 10.
@@ -82,7 +82,7 @@ TODO: Replaced task with:
EOF EOF
echo 'jump on hay' > todo.txt echo 'jump on hay' > todo.txt
test_todo_session 'replace with &' << EOF test_todo_session 'replace with &' <<EOF
>>> todo.sh replace 1 "thrash the hay & thrash the wheat" >>> todo.sh replace 1 "thrash the hay & thrash the wheat"
1 jump on hay 1 jump on hay
TODO: Replaced task with: TODO: Replaced task with:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -17,7 +17,7 @@ test_todo_session 'append usage' <<EOF
usage: todo.sh append ITEM# "TEXT TO APPEND" usage: todo.sh append ITEM# "TEXT TO APPEND"
EOF EOF
test_todo_session 'append error' << EOF test_todo_session 'append error' <<EOF
>>> todo.sh append 10 "hej!" >>> todo.sh append 10 "hej!"
=== 1 === 1
TODO: No task 10. TODO: No task 10.

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
#
test_description='todo.sh configuration with a sole todo.txt data file. test_description='todo.sh configuration with a sole todo.txt data file.
@@ -8,7 +7,7 @@ checks that no such empty files are created.
' '
. ./test-lib.sh . ./test-lib.sh
cat > test.cfg << EOF cat > test.cfg <<EOF
export TODO_DIR=. export TODO_DIR=.
export TODO_FILE="\$TODO_DIR/todo.txt" export TODO_FILE="\$TODO_DIR/todo.txt"
export DONE_FILE=/dev/null export DONE_FILE=/dev/null

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
#
test_description='Bash add-on action completion functionality test_description='Bash add-on action completion functionality
@@ -74,7 +73,7 @@ removeCustomActions "$HOME/.todo.actions.d"
# #
# Test resolution of an alternative TODO_ACTIONS_DIR. # Test resolution of an alternative TODO_ACTIONS_DIR.
# #
mkdir "$HOME/.todo" mkdir "$HOME/.todo"
makeCustomActions "$HOME/.todo/actions" makeCustomActions "$HOME/.todo/actions"
test_todo_completion 'all arguments with actions from .todo/actions/' 'todo.sh ' "$ACTIONS $ADDONS $CONTAINED $OPTIONS" test_todo_completion 'all arguments with actions from .todo/actions/' 'todo.sh ' "$ACTIONS $ADDONS $CONTAINED $OPTIONS"
removeCustomActions "$HOME/.todo/actions" removeCustomActions "$HOME/.todo/actions"

View File

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

View File

@@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
#
test_description='Bash completion with different path functionality 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' 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 # Remove the test environment's bin directory from the PATH, so that our test
# executable must be launched with an explicit path. # executable must be launched with an explicit path.
PATH=${PATH##"${PWD}/bin:"} PATH=${PATH##"${PWD}/bin:"}

View File

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

View File

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

View File

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

13
todo.sh
View File

@@ -134,7 +134,6 @@ $indentedJoinedConfigFileLocations
-x -x
Disables TODOTXT_FINAL_FILTER Disables TODOTXT_FINAL_FILTER
EndOptionsHelp EndOptionsHelp
[ "$TODOTXT_VERBOSE" -gt 1 ] && cat <<-'EndVerboseHelp' [ "$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_VALID_PATTERN=.* tweak the allowed chars for +p and @c
TODOTXT_SIGIL_AFTER_PATTERN="" optionally allow chars after +p / @c TODOTXT_SIGIL_AFTER_PATTERN="" optionally allow chars after +p / @c
EndVerboseHelp EndVerboseHelp
actionsHelp actionsHelp
addonHelp addonHelp
@@ -710,7 +708,6 @@ do
fi fi
done done
if [ -z "$TODO_ACTIONS_DIR" ] || [ ! -d "$TODO_ACTIONS_DIR" ] if [ -z "$TODO_ACTIONS_DIR" ] || [ ! -d "$TODO_ACTIONS_DIR" ]
then then
TODO_ACTIONS_DIR="$HOME/.todo/actions" TODO_ACTIONS_DIR="$HOME/.todo/actions"
@@ -788,7 +785,7 @@ ACTION=${1:-$TODOTXT_DEFAULT_ACTION}
if [ $TODOTXT_PLAIN = 1 ]; then if [ $TODOTXT_PLAIN = 1 ]; then
for clr in ${!PRI_@}; do for clr in ${!PRI_@}; do
export "$clr"=$NONE export "$clr"="$NONE"
done done
PRI_X=$NONE PRI_X=$NONE
DEFAULT=$NONE DEFAULT=$NONE
@@ -1093,7 +1090,7 @@ case $action in
SAVEIFS=$IFS SAVEIFS=$IFS
IFS=$'\n' IFS=$'\n'
# Treat each line seperately # Treat each line separately
for line in $input ; do for line in $input ; do
_addto "$TODO_FILE" "$line" _addto "$TODO_FILE" "$line"
done done
@@ -1136,7 +1133,7 @@ case $action in
if [ "$TODOTXT_VERBOSE" -gt 0 ]; then if [ "$TODOTXT_VERBOSE" -gt 0 ]; then
getNewtodo "$item" getNewtodo "$item"
echo "$item $newtodo" echo "$item $newtodo"
fi fi
else else
die "TODO: Error appending task $item." die "TODO: Error appending task $item."
fi fi
@@ -1149,7 +1146,7 @@ case $action in
grep "^x " "$TODO_FILE" >> "$DONE_FILE" grep "^x " "$TODO_FILE" >> "$DONE_FILE"
sed -i.bak '/^x /d' "$TODO_FILE" sed -i.bak '/^x /d' "$TODO_FILE"
if [ "$TODOTXT_VERBOSE" -gt 0 ]; then if [ "$TODOTXT_VERBOSE" -gt 0 ]; then
echo "TODO: $TODO_FILE archived." echo "TODO: $TODO_FILE archived."
fi fi
;; ;;
@@ -1240,7 +1237,7 @@ case $action in
getNewtodo "$item" getNewtodo "$item"
echo "$item $newtodo" echo "$item $newtodo"
echo "TODO: $item marked as done." echo "TODO: $item marked as done."
fi fi
else else
echo "TODO: $item is already marked done." echo "TODO: $item is already marked done."
fi fi

View File

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