Skip to content

Commit 743d0a9

Browse files
committed
fix(_known_hosts): use array for options (work around SC2178,SC2179)
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).
1 parent 2b3f854 commit 743d0a9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bash_completion

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,11 +2265,11 @@ _known_hosts()
22652265

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

22752275
# Helper function to locate ssh included files in configs

0 commit comments

Comments
 (0)