From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24323 invoked by alias); 30 Mar 2017 15:21:24 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40918 Received: (qmail 24388 invoked from network); 30 Mar 2017 15:21:24 -0000 X-Qmail-Scanner-Diagnostics: from king.bitgnome.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(167.88.119.192):SA:0(-0.0/5.0):. Processed in 0.867473 secs); 30 Mar 2017 15:21:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RP_MATCHES_RCVD,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: nipsy@bitgnome.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at bitgnome.net designates 167.88.119.192 as permitted sender) Date: Thu, 30 Mar 2017 10:21:14 -0500 From: Mark Nipper To: Daniel Shahaf Cc: zsh-workers@zsh.org Subject: Re: patch for ssh completion Message-ID: <20170330152114.ozv5utiplxcvxapd@king.bitgnome.net> References: <20170302121229.GC6315@fujitsu.shahaf.local2> <20170329231101.f2fqlxb3b5xgnmro@king.bitgnome.net> <20170329234157.GA15475@fujitsu.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170329234157.GA15475@fujitsu.shahaf.local2> User-Agent: NeoMutt/20170113 (1.7.2) X-Virus-Scanned: clamav-milter 0.99.2 at king.bitgnome.net X-Virus-Status: Clean On 29 Mar 2017, Daniel Shahaf wrote: > Mark Nipper wrote on Wed, Mar 29, 2017 at 18:11:01 -0500: > > I also wasn't sure if certain shell options should be > > assumed for these completion functions. I am assuming MULTIOS in > > this particular example for the included file array to be read > > correctly. > > Completions options are run with the options from ${_comp_options} (in > compinit) in effect; you need an explicit «setopt localoptions multios» > in this case. > > (@workers feel free to review/apply the patch; I might if I have time, > but I can't promise) I assume putting that into that one function then would be the correct way to set that. Added that to the patch: --- Completion/Unix/Command/_ssh.orig 2016-11-25 14:24:09.000000000 -0600 +++ Completion/Unix/Command/_ssh 2017-03-30 08:53:03.103396162 -0500 @@ -1,5 +1,7 @@ #compdef ssh slogin=ssh scp ssh-add ssh-agent ssh-keygen sftp ssh-copy-id +local -a config_includes + # TODO: sshd, ssh-keyscan, ssh-keysign _ssh () { @@ -662,7 +664,29 @@ _combination -s '[:@]' my-accounts users-hosts users "$@" } +_ssh_includes () { + local key includes + if [[ -r $@ ]]; then + config_includes+=("$@") + else + return 1 + fi + + while IFS=$'=\t ' read -r key includes; do + if [[ "$key" == (#i)include ]]; then + if [[ ${includes[1]} == / ]]; then + _ssh_includes $includes + else + _ssh_includes $HOME/.ssh/$includes + fi + fi + done < "$@" + + return 0 +} + _ssh_hosts () { + setopt localoptions multios local -a config_hosts local config integer ind @@ -679,7 +703,7 @@ else config="$HOME/.ssh/config" fi - if [[ -r $config ]]; then + if _ssh_includes $config; then local key hosts host while IFS=$'=\t ' read -r key hosts; do if [[ "$key" == (#i)host ]]; then @@ -690,7 +714,7 @@ esac done fi - done < "$config" + done < ${config_includes} if (( ${#config_hosts} )); then _wanted hosts expl 'remote host name' \ compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" $config_hosts -- Mark Nipper nipsy@bitgnome.net (XMPP) - ¸.·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º>