zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] _ssh_hosts: abort early if in a path
@ 2019-05-27 23:33 Phil Pennock
  2019-05-29 13:57 ` Jun-ichi Takimoto
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Pennock @ 2019-05-27 23:33 UTC (permalink / raw)
  To: zsh-workers

The SSH hosts completion is often used in a context where a host or a
file is being matched; with host completion happening first, there can
be a lot of work parsing complex SSH configs and thus that can be slow.

Assuming that for the purposes of SSH, no hostname starts `./` or `/`,
abort early on trying to complete a hostname which starts with one of
those.

UNC paths shouldn't be an issue for SSH, I don't _think_.
---
 Completion/Unix/Type/_ssh_hosts | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Completion/Unix/Type/_ssh_hosts b/Completion/Unix/Type/_ssh_hosts
index e20142cfd..7e40f3fa7 100644
--- a/Completion/Unix/Type/_ssh_hosts
+++ b/Completion/Unix/Type/_ssh_hosts
@@ -4,6 +4,15 @@ local -a config_hosts
 local config
 integer ind
 
+# If it looks like a path, it's not a host for our purposes, abort early so
+# that combined path+host matching can more efficiently deal with local
+# paths.
+case "$PREFIX" in
+  ( /* | ./* )
+    return
+    ;;
+esac
+
 # If users-hosts matches, we shouldn't complete anything else.
 if [[ "$IPREFIX" == *@ ]]; then
   _combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@" && return
-- 
2.21.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-29 21:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-27 23:33 [PATCH] _ssh_hosts: abort early if in a path Phil Pennock
2019-05-29 13:57 ` Jun-ichi Takimoto
2019-05-29 21:50   ` Phil Pennock

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).