Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: Fix all ShellCheck errors and most warnings #419

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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