From: Sebastian Gniazdowski <psprint3@fastmail.com>
To: zsh-workers@zsh.org
Subject: Re: PATCH: Don't use =~ for simple prefix match
Date: Mon, 06 Mar 2017 22:50:15 -0800 [thread overview]
Message-ID: <1488869415.4132903.902877024.7D41352B@webmail.messagingengine.com> (raw)
In-Reply-To: <20170307021849.11740-1-mikachu@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 504 bytes --]
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@fastmail.com
[-- Attachment #2: hosts_no_regex.diff --]
[-- Type: text/plain, Size: 711 bytes --]
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
next prev parent reply other threads:[~2017-03-07 6:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-07 2:18 Mikael Magnusson
2017-03-07 6:50 ` Sebastian Gniazdowski [this message]
2017-03-07 7:01 ` Sebastian Gniazdowski
2017-03-07 9:33 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1488869415.4132903.902877024.7D41352B@webmail.messagingengine.com \
--to=psprint3@fastmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).