Skip to content
Myr

[bash] Set shell options for pathname expansion "~/.ssh/config.d/*" (#4405)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Koichi Murase · committed by GitHub · parent 70eace5 · Browse files · 1 file+17 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+17 added−1 removed

  • other:+17 added−1 removed

1 file+17 added−1 removed

modified:shell/completion.bash+17 added-1 removed
458 unmodified lines
459# printf '%s\n' "${COMPREPLY[@]}" | command sort -u --version-sort460# }461if ! declare -F __fzf_list_hosts > /dev/null; then462 __fzf_list_hosts() {463 command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | command awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?%]') \463 command cat \464 <(465 # Note: To make the pathname expansion of "~/.ssh/config.d/*" work466 # properly, we need to adjust the related shell options. We need to467 # unset "set -f" and "GLOBIGNORE", which disable the pathname expansion468 # totally or partially. We need to unset "dotglob" and "nocaseglob" to469 # avoid matching unwanted files. We need to unset "failglob" to avoid470 # outputting the error messages to the terminal when no matching is471 # found. We need to set "nullglob" to avoid attempting to read the472 # literal filename '~/.ssh/config.d/*' when no matching is found.473 set +f474 GLOBIGNORE=475 shopt -u dotglob nocaseglob failglob476 shopt -s nullglob477478 command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | command awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?%]'479 ) \480 <(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts 2> /dev/null | command tr ',' '\n' | command tr -d '[' | command awk '{ print $1 " " $1 }') \481 <(command grep -v '^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv '0.0.0.0' | command sed 's/#.*//') |482 command awk '{for (i = 2; i <= NF; i++) print $i}' | command sort -u483 }
158 unmodified lines