Skip to content

Commit

Permalink
lint: Fix all ShellCheck errors and most warnings (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperupcall authored Dec 26, 2024
1 parent 86a2058 commit e15ad82
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions todo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,14 @@ die()

confirm()
{
[ $TODOTXT_FORCE = 0 ] || return 0
[ "$TODOTXT_FORCE" = 0 ] || return 0

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

# shellcheck source=./todo.cfg
. "$TODOTXT_CFG_FILE"

# === APPLY OVERRIDES
Expand Down Expand Up @@ -922,16 +924,18 @@ _format()
fi
items=$(
if [ "$FILE" ]; then
# shellcheck disable=SC2283
sed = "$FILE"
else
# shellcheck disable=SC2283
sed =
fi \
| sed -e '''
| sed -e '
N
s/^/ /
s/ *\([ 0-9]\{'"$PADDING"',\}\)\n/\1 /
/^[ 0-9]\{1,\} *$/d
'''
'
)

## Build and apply the filter.
Expand Down Expand Up @@ -1007,12 +1011,12 @@ _format()
printf "%s\n", end_clr
}
''' \
| sed '''
| sed '
s/'"${HIDE_PROJECTS_SUBSTITUTION:-^}"'//g
s/'"${HIDE_CONTEXTS_SUBSTITUTION:-^}"'//g
s/'"${HIDE_CUSTOM_SUBSTITUTION:-^}"'//g
''' \
| eval ${TODOTXT_FINAL_FILTER} \
' \
| eval ${TODOTXT_FINAL_FILTER} \
)
[ "$filtered_items" ] && echo "$filtered_items"

Expand Down

0 comments on commit e15ad82

Please sign in to comment.