mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-06-10 06:48:03 +02:00
52798: handle comments in ssh config
This commit is contained in:
parent
b727b74fe2
commit
c7ae370160
3 changed files with 11 additions and 8 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2024-03-25 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
|
* 52798: Completion/Unix/Command/_ssh,
|
||||||
|
Completion/Unix/Type/_ssh_hosts: handle comments in ssh config
|
||||||
|
|
||||||
2024-03-23 Mikael Magnusson <mikachu@gmail.com>
|
2024-03-23 Mikael Magnusson <mikachu@gmail.com>
|
||||||
|
|
||||||
* 52768: Completion/compdump, Completion/compinit: Handle
|
* 52768: Completion/compdump, Completion/compinit: Handle
|
||||||
|
|
|
@ -101,6 +101,7 @@ _ssh () {
|
||||||
'--apple-use-keychain[update keychain when adding/removing identities]'
|
'--apple-use-keychain[update keychain when adding/removing identities]'
|
||||||
)
|
)
|
||||||
_arguments -C -s : $args \
|
_arguments -C -s : $args \
|
||||||
|
'-C[process certificates only]' \
|
||||||
'-c[identity is subject to confirmation via SSH_ASKPASS]' \
|
'-c[identity is subject to confirmation via SSH_ASKPASS]' \
|
||||||
'-D[delete all identities]' \
|
'-D[delete all identities]' \
|
||||||
'-d[remove identity]' \
|
'-d[remove identity]' \
|
||||||
|
@ -214,7 +215,7 @@ _ssh () {
|
||||||
"(${${(@)cmds:#-p}} -v ${${(@)cms:#-[qt]}})-N+[provide new passphrase]:new passphrase" \
|
"(${${(@)cmds:#-p}} -v ${${(@)cms:#-[qt]}})-N+[provide new passphrase]:new passphrase" \
|
||||||
"(${${(@)cmds:#-c}} -v $cms)-C+[provide new comment]:new comment" \
|
"(${${(@)cmds:#-c}} -v $cms)-C+[provide new comment]:new comment" \
|
||||||
"(-D -I -h -n -V -A)-f+[$file file]:$file file:_files" \
|
"(-D -I -h -n -V -A)-f+[$file file]:$file file:_files" \
|
||||||
"$p1(${${(@)cmds:#-[FE]}} ${${(@)cmn:#-v}} ${${(@)cms:#-E}})-l[show fingerprint of key file]" \
|
"(${${(@)cmds:#-[FE]}} ${${(@)cmn:#-v}} ${${(@)cms:#-E}})-l[show fingerprint of key file]" \
|
||||||
"$p1(${${(@)cmds:#-[iep]}} $cms)-m+[specify conversion format]:format [RFC4716]:(PEM PKCS8 RFC4716)" \
|
"$p1(${${(@)cmds:#-[iep]}} $cms)-m+[specify conversion format]:format [RFC4716]:(PEM PKCS8 RFC4716)" \
|
||||||
"$p1*-O+[specify a key/value option]: : _values 'option' $options" \
|
"$p1*-O+[specify a key/value option]: : _values 'option' $options" \
|
||||||
"(${${(@)cmds:#-[lGT]}} ${${(@)cmn:#-[bv]}} -f)*-v[verbose mode]" \
|
"(${${(@)cmds:#-[lGT]}} ${${(@)cmn:#-[bv]}} -f)*-v[verbose mode]" \
|
||||||
|
|
|
@ -24,7 +24,7 @@ if [[ -r $config ]]; then
|
||||||
while (( idx <= $#lines )); do
|
while (( idx <= $#lines )); do
|
||||||
IFS=$'=\t ' read -r key line <<<"${lines[idx]}"
|
IFS=$'=\t ' read -r key line <<<"${lines[idx]}"
|
||||||
if [[ "$key" == ((#i)match) ]]; then
|
if [[ "$key" == ((#i)match) ]]; then
|
||||||
match_args=(${(z)line})
|
match_args=( ${(Z.C.)line} )
|
||||||
while [[ $#match_args -ge 2 ]]; do
|
while [[ $#match_args -ge 2 ]]; do
|
||||||
if [[ "${match_args[1]}" == (#i)(canonical|final|(|original)host) ]]; then
|
if [[ "${match_args[1]}" == (#i)(canonical|final|(|original)host) ]]; then
|
||||||
key="Host"
|
key="Host"
|
||||||
|
@ -36,13 +36,10 @@ if [[ -r $config ]]; then
|
||||||
fi
|
fi
|
||||||
case "$key" in
|
case "$key" in
|
||||||
((#i)include)
|
((#i)include)
|
||||||
lines[idx]=("${(@f)$(cd $HOME/.ssh; cat ${(z)~line})}") 2>/dev/null;;
|
lines[idx]=( "${(@f)$(cd $HOME/.ssh; cat ${(Z.C.)~line} 2>/dev/null)}" ) ;;
|
||||||
((#i)host(|name))
|
((#i)host(|name))
|
||||||
for host in ${(z)line}; do
|
for host in ${(Z.C.)line}; do
|
||||||
case $host in
|
[[ $host != *[*?%]* ]] && config_hosts+=( $host )
|
||||||
(*[*?]*) ;;
|
|
||||||
(*) config_hosts+=("$host") ;;
|
|
||||||
esac
|
|
||||||
done ;&
|
done ;&
|
||||||
(*) (( ++idx ));;
|
(*) (( ++idx ));;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue