Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: Don't use =~ for simple prefix match
- X-seq: zsh-workers 40782
- From: Sebastian Gniazdowski <psprint3@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: PATCH: Don't use =~ for simple prefix match
- Date: Mon, 06 Mar 2017 22:50:15 -0800
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=ki74GKq2854pkSGfGJd2mv06SV I=; b=VY2z9iyhWtsHm6sanU2fF+w1ne2xvsZaokgIC+xAs4vbsIJq3Qd0LhITkd 1t6PhD5paqkwayFsnZk2jacdExM17VMKbmKfQDSl/q1CsgPyAWcmXmfE5ac5YKnK M8BggyTgqQEyHZYcLEE/BgW3kglJy0TdOgxkgYM4hEaBKFoK0=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=smtpout; bh=ki 74GKq2854pkSGfGJd2mv06SVI=; b=jwltJCGbBVDW9pHO+rKcbYOnZ9PK9Dh9zj uAUq/e7hTTcrW4XYAFbsUFezvwLM04szpVpJCAZ2c1Fzqw5bnvU0OtdRTzlCv2sW k/8uJomx2zbmdxMcANg77Z67tRk6ccY//sX45epK47ceuOWMOq7wdLfBmU43SnDd gaACJ+NHM=
- In-reply-to: <20170307021849.11740-1-mikachu@gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20170307021849.11740-1-mikachu@gmail.com>
On Mon, Mar 6, 2017, at 06:18 PM, Mikael Magnusson wrote:
> - if [[ "${OSTYPE}" =~ freebsd.* ]]; then
> + if [[ "${OSTYPE}" = freebsd* ]]; then
Did similar for _hosts:
- elif [[ $host =~ "\[(.*)\]:\d*" ]]; then
- khosts+=$match
+ elif [[ $host = (#b)*\[(*)\]:[[:digit:]]#* ]]; then
+ khosts+=${match[1]}
Also localized match parameters.
Had to add wrapping stars because =~ matches substrings.
--
Sebastian Gniazdowski
psprint3@xxxxxxxxxxxx
diff --git a/Completion/Unix/Type/_hosts b/Completion/Unix/Type/_hosts
index 5654086..d9e1090 100644
--- a/Completion/Unix/Type/_hosts
+++ b/Completion/Unix/Type/_hosts
@@ -50,12 +50,13 @@ if ! zstyle -a ":completion:${curcontext}:hosts" hosts _hosts; then
# entries.
() {
local host
+ local -a match mbegin mend
khosts=()
for host; do
if [[ $host == *[*?]* ]]; then
continue
- elif [[ $host =~ "\[(.*)\]:\d*" ]]; then
- khosts+=$match
+ elif [[ $host = (#b)*\[(*)\]:[[:digit:]]#* ]]; then
+ khosts+=${match[1]}
else
khosts+=$host
fi
Messages sorted by:
Reverse Date,
Date,
Thread,
Author