zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] _hosts: Don't complete wildcard entries from ~/.ssh/known_hosts.
@ 2016-07-29 17:50 Daniel Shahaf
  0 siblings, 0 replies; only message in thread
From: Daniel Shahaf @ 2016-07-29 17:50 UTC (permalink / raw)
  To: zsh-workers

---
 Completion/Unix/Type/_hosts | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/Completion/Unix/Type/_hosts b/Completion/Unix/Type/_hosts
index c3133dc..5654086 100644
--- a/Completion/Unix/Type/_hosts
+++ b/Completion/Unix/Type/_hosts
@@ -45,13 +45,22 @@ if ! zstyle -a ":completion:${curcontext}:hosts" hosts _hosts; then
 
         # known_hosts syntax supports the host being in the form [hostname]:port
         # The filter below extracts the hostname from lines using this format.
-        khosts=($(for host ($khosts); do
-          if [[ $host =~ "\[(.*)\]:\d*" ]]; then
-            echo $match
-          else
-            echo $host
-          fi
-        done))
+        #
+        # known_hosts syntax supports wildcards.  The filter below removes wildcard
+        # entries.
+        () {
+          local host
+          khosts=()
+          for host; do
+            if [[ $host == *[*?]* ]]; then
+              continue
+            elif [[ $host =~ "\[(.*)\]:\d*" ]]; then
+              khosts+=$match
+            else
+              khosts+=$host
+            fi
+          done
+        } "$khosts[@]"
 
         if [[ -z $useip ]]; then
           khosts=(${${khosts:#(#s)[0-9]##.[0-9]##.[0-9]##.[0-9]##(#e)}:#(#s)[0-9a-f:]##(#e)})


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-07-29 17:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-29 17:50 [PATCH] _hosts: Don't complete wildcard entries from ~/.ssh/known_hosts Daniel Shahaf

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).