Fix for `shellcheck` compliance

This commit is contained in:
rwxrob 2021-08-18 20:54:40 -04:00
parent 12ab9206e3
commit d022b32e71
No known key found for this signature in database
GPG Key ID: 1CCACEDD2F65578E
1 changed files with 8 additions and 11 deletions

19
cmd
View File

@ -119,10 +119,10 @@ command_usage() {
local -a cmds
for c in "${COMMANDS[@]}"; do
[[ ${c:0:1} =~ _ ]] && continue
cmds+=($c)
cmds+=("$c")
done
cmds="${cmds[*]}"
printf "usage: %s (%s)\n" "$EXE" "${cmds// /|}"
local IFS='|'
printf "usage: %s (%s)\n" "$EXE" "${cmds[*]}"
}
help[help]='
@ -144,7 +144,7 @@ Also see `readme` and `usage` commands.
'
command_help() {
local name="${1:-main}" title own body
local name="${1:-main}" title body
title=$(_help_title "$name") || true
if [[ -z "$title" ]]; then
body="${help[$name]}"
@ -152,7 +152,6 @@ command_help() {
[[ $name = main ]] && title="$EXE"
else
body="${help[$name]}"
local eol=$'\n'
body=${body#*$title}
fi
local file="/tmp/help-$EXE-$name.html"
@ -183,14 +182,11 @@ GitHub or similar hosting service. '
command_readme() {
_trim "${help[main]}"
local usage="$(command_usage)"
printf "\n## Commands\n\n"
local -a names=("${!help[@]}")
while IFS= read -r name; do
[[ $name = main ]] && continue
local body=$(_trim "${help[$name]}")
body=$(_trim "${help[$name]}")
[[ $body =~ ^\# ]] || body="# The \`$name\` Command\n\n$body"
printf "##$body\n\n"
printf "##%s\n\n" "$body"
done < <(printf "%s\n" "${!help[@]}" | LC_COLLATE=C sort)
echo -e "----\n\n*Autogenerated $(date)*\n"
}
@ -236,7 +232,8 @@ while IFS= read -r line; do
[[ $line =~ ^declare\ -f\ command_ ]] || continue
COMMANDS+=( "${line##declare -f command_}" )
done < <(declare -F)
COMMANDS=($(LC_COLLATE=C sort < <(printf "%s\n" "${COMMANDS[@]}")))
mapfile -t COMMANDS < \
<(LC_COLLATE=C sort < <(printf "%s\n" "${COMMANDS[@]}"))
if [[ -n $COMP_LINE ]]; then
line=${COMP_LINE#* }