Skip to content

Commit e15ad82

Browse files
authored
lint: Fix all ShellCheck errors and most warnings (#419)
1 parent 86a2058 commit e15ad82

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

todo.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,14 @@ die()
362362

363363
confirm()
364364
{
365-
[ $TODOTXT_FORCE = 0 ] || return 0
365+
[ "$TODOTXT_FORCE" = 0 ] || return 0
366366

367367
local readArgs=(-e -r)
368-
[ -n "${BASH_VERSINFO:-}" ] && [ \( ${BASH_VERSINFO[0]} -eq 4 -a ${BASH_VERSINFO[1]} -ge 1 \) -o ${BASH_VERSINFO[0]} -gt 4 ] &&
368+
if [ -n "${BASH_VERSINFO:-}" ] && ((BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 1) )); then
369369
readArgs+=(-N 1) # Bash 4.1+ supports -N nchars
370+
fi
370371
local answer
371-
read -p "${1:?}? (y/n) " "${readArgs[@]}" answer
372+
read -rp "${1:?}? (y/n) " "${readArgs[@]}" answer
372373
echo
373374
[ "$answer" = "y" ]
374375
}
@@ -739,6 +740,7 @@ done
739740
# === SANITY CHECKS (thanks Karl!) ===
740741
[ -r "$TODOTXT_CFG_FILE" ] || dieWithHelp "$1" "Fatal Error: Cannot read configuration file ${TODOTXT_CFG_FILE:-${configFileLocations[0]}}"
741742

743+
# shellcheck source=./todo.cfg
742744
. "$TODOTXT_CFG_FILE"
743745

744746
# === APPLY OVERRIDES
@@ -922,16 +924,18 @@ _format()
922924
fi
923925
items=$(
924926
if [ "$FILE" ]; then
927+
# shellcheck disable=SC2283
925928
sed = "$FILE"
926929
else
930+
# shellcheck disable=SC2283
927931
sed =
928932
fi \
929-
| sed -e '''
933+
| sed -e '
930934
N
931935
s/^/ /
932936
s/ *\([ 0-9]\{'"$PADDING"',\}\)\n/\1 /
933937
/^[ 0-9]\{1,\} *$/d
934-
'''
938+
'
935939
)
936940

937941
## Build and apply the filter.
@@ -1007,12 +1011,12 @@ _format()
10071011
printf "%s\n", end_clr
10081012
}
10091013
''' \
1010-
| sed '''
1014+
| sed '
10111015
s/'"${HIDE_PROJECTS_SUBSTITUTION:-^}"'//g
10121016
s/'"${HIDE_CONTEXTS_SUBSTITUTION:-^}"'//g
10131017
s/'"${HIDE_CUSTOM_SUBSTITUTION:-^}"'//g
1014-
''' \
1015-
| eval ${TODOTXT_FINAL_FILTER} \
1018+
' \
1019+
| eval ${TODOTXT_FINAL_FILTER} \
10161020
)
10171021
[ "$filtered_items" ] && echo "$filtered_items"
10181022

0 commit comments

Comments
 (0)