Skip to content

Commit

Permalink
fix(_known_hosts): use array for options (work around SC2178,SC2179)
Browse files Browse the repository at this point in the history
shellcheck does not allow using a local scalar variable that has the
same variable name as an array variable used in another function
(SC2178,SC2179).  To use array `options` in another function, we
switch `options` in `_known_hosts` to an array variable (or otherwise,
we will need to place disable=SC2178,SC2179 to every line using the
variable as a scalar).
  • Loading branch information
akinomyoga committed Aug 20, 2023
1 parent 2b3f854 commit 743d0a9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -2265,11 +2265,11 @@ _known_hosts()

# NOTE: Using `_known_hosts' as a helper function and passing options
# to `_known_hosts' is deprecated: Use `_known_hosts_real' instead.
local options=""
[[ ${1-} == -a || ${2-} == -a ]] && options=-a
[[ ${1-} == -c || ${2-} == -c ]] && options+=" -c"
# shellcheck disable=SC2086
_known_hosts_real ${options-} -- "$cur"
local -a options=()
[[ ${1-} == -a || ${2-} == -a ]] && options+=(-a)
[[ ${1-} == -c || ${2-} == -c ]] && options+=(-c)
local IFS=$' \t\n' # Workaround for connected ${v+"$@"} in bash < 4.4
_known_hosts_real ${options[@]+"${options[@]}"} -- "$cur"
} # _known_hosts()

# Helper function to locate ssh included files in configs
Expand Down

0 comments on commit 743d0a9

Please sign in to comment.