Improve variable handling in `_print_entries()`.

This commit is contained in:
William Melody 2020-06-07 13:49:48 -07:00
parent 4238e8bd81
commit f585447612
2 changed files with 12 additions and 4 deletions

View File

@ -5,6 +5,14 @@
# https://github.com/koalaman/shellcheck/wiki/Ignore
###############################################################################
# Disable SC2183
#
# Running into this: https://github.com/koalaman/shellcheck/issues/1310
# TODO: Check if resolved.
#
#https://github.com/koalaman/shellcheck/wiki/SC2183
disable=SC2183
# Disable SC2206 and SC2207
#
# `IFS` and `noglob` are set.

8
hosts
View File

@ -344,7 +344,7 @@ _print_entries() {
fi
done <<< "${_input}"
_max_divided="$((_max_length / 8))"
local _max_quotient="$((_max_length / 8))"
while IFS=$'\t ' read -r -a _parts
do
@ -354,9 +354,9 @@ _print_entries() {
printf "disabled:\\n"
fi
_current_divided=$((${#_parts[0]} / 8))
_tab_count=$((_max_divided - _current_divided + 1))
# shellcheck disable=SC2183
local _current_quotient=$((${#_parts[0]} / 8))
local _tab_count=$((_max_quotient - _current_quotient + 1))
local _tabs=
_tabs="$(printf "%*s" ${_tab_count} | tr " " '\t')"
if [[ -n "${_parts[2]:-}" ]]