Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] _ssh_hosts: abort early if in a path
- X-seq: zsh-workers 44372
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] _ssh_hosts: abort early if in a path
- Date: Mon, 27 May 2019 19:33:32 -0400
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d201905; h=Content-Type:MIME-Version:Message-ID:Subject:To: From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=i2WylP5/zjkCxFu6zWNbhZdhut+hns26nvwogDqbCEw=; b=tGv9ku1gltUkODW/TzO8VuYMGL l0bG5ebJxUBJoqwKIokpw/FmbA1J68QbnVTCuJjl8jhqiJGvi67dUdS/wY6PN8VgBT0a7cBmHKDVq 17vLp11PsIWYr00iCYjoyJy1JR0RGWCOTCmgDNSCp8oIPv3v7ZgvlC0w8NHpy9Lwy6tpTXBGtqr6x 6GSPDaY/AlKnP4ulxjVnsGXt3yUHgNHVagDFL/hdKWoWw34tHHib2KjK/xNOpZfiBMRv9u7ZyDspi 5LhfQQDZGMMIEZYGlt3TGjV/vGSdnAP5lvCIWSxwHnLQxORLrvVj/bqa3drs+xDkgBK96NegE7sAv 5E0Fz/mw==;
- Dkim-signature: v=1; a=ed25519-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d201905e2; h=Content-Type:MIME-Version:Message-ID:Subject: To:From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=i2WylP5/zjkCxFu6zWNbhZdhut+hns26nvwogDqbCEw=; b=FuWzUEWWtcuiqXxzB2LkxOJZRt T54pA0zZSnfkWA5jahz/YoImHW0HPgPlN0QLIhByNalZTVpK/UjJ4JgiCoBg==;
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Openpgp: url=https://www.security.spodhuis.org/PGP/keys/0x4D1E900E14C1CC04.asc
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author