* PATCH: Don't use =~ for simple prefix match
@ 2017-03-07 2:18 Mikael Magnusson
2017-03-07 6:50 ` Sebastian Gniazdowski
0 siblings, 1 reply; 4+ messages in thread
From: Mikael Magnusson @ 2017-03-07 2:18 UTC (permalink / raw)
To: zsh-workers
---
Completion/Unix/Command/_mount | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Completion/Unix/Command/_mount b/Completion/Unix/Command/_mount
index 7c5605016e..9ab279d754 100644
--- a/Completion/Unix/Command/_mount
+++ b/Completion/Unix/Command/_mount
@@ -619,7 +619,7 @@ if (( ! $+_fs_any )); then
'longnames[force Windows 95 long filenames to be visible]'
'nowin95[completely ignore Windows 95 extended file information]'
)
- if [[ "${OSTYPE}" =~ freebsd.* ]]; then
+ if [[ "${OSTYPE}" = freebsd* ]]; then
_fs_msdosfs=( "$_fs_msdos[@]" )
fi
;;
--
2.8.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: Don't use =~ for simple prefix match
2017-03-07 2:18 PATCH: Don't use =~ for simple prefix match Mikael Magnusson
@ 2017-03-07 6:50 ` Sebastian Gniazdowski
2017-03-07 7:01 ` Sebastian Gniazdowski
0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Gniazdowski @ 2017-03-07 6:50 UTC (permalink / raw)
To: zsh-workers
[-- 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: Don't use =~ for simple prefix match
2017-03-07 6:50 ` Sebastian Gniazdowski
@ 2017-03-07 7:01 ` Sebastian Gniazdowski
2017-03-07 9:33 ` Peter Stephenson
0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Gniazdowski @ 2017-03-07 7:01 UTC (permalink / raw)
To: zsh-workers
One thing, (#b) needs extendedglob, not sure if completion provides it.
However the code was already in anonymous function, so "setopt
localoptions extendedglob" can be easily added.
--
Sebastian Gniazdowski
psprint3@fastmail.com
On Mon, Mar 6, 2017, at 10:50 PM, Sebastian Gniazdowski wrote:
> 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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: Don't use =~ for simple prefix match
2017-03-07 7:01 ` Sebastian Gniazdowski
@ 2017-03-07 9:33 ` Peter Stephenson
0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2017-03-07 9:33 UTC (permalink / raw)
To: zsh-workers
On Mon, 06 Mar 2017 23:01:18 -0800
Sebastian Gniazdowski <psprint3@fastmail.com> wrote:
> One thing, (#b) needs extendedglob, not sure if completion provides it.
> However the code was already in anonymous function, so "setopt
> localoptions extendedglob" can be easily added.
EXTENDED_GLOB is turned on at the top of completion --- see the list
_comp_options in compinit.
pws
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-07 9:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-07 2:18 PATCH: Don't use =~ for simple prefix match Mikael Magnusson
2017-03-07 6:50 ` Sebastian Gniazdowski
2017-03-07 7:01 ` Sebastian Gniazdowski
2017-03-07 9:33 ` Peter Stephenson
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).