Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Feature request: #a (approximate matching) only for spaces
- X-seq: zsh-users 21309
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Feature request: #a (approximate matching) only for spaces
- Date: Sat, 20 Feb 2016 11:16:03 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=9IsNlD5yX8jynutTDgmoC915gi2ADtlsFj7+zYshUos=; b=ClprS/t4HIdaj3tQEMW60e7C7vQZWcJDwLWi0FMshqKRJXs8DDCLvWqC6mq+O7nuO6 yErndo9FkvRAp4tbKl76wzBsyX/SPF8Nw8/HmNoXamGWZDtgwijfzcr20pRCmAPtZTXz lkJcqngF4CiCRC0u7Ygv5Zk4W/In84uJ/rrJ/tFfTpLDBeESddkkTscc33GVk+hkR8aQ suezNrOwoYmRc1Q0HXqilrNswQNc2pS3FMuDcNbcUMFn/duGqVmS12K7b35t4CiuEKcK mW2nMkFLaTa9Hjdb7yA5SmFH4Wpo0xuOTX7UE598p9Ock+JUdSXCsqfNMaMoq3C3lO1T i0Iw==
- In-reply-to: <160219111327.ZM17643@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVATpn35B0mNzKQQFCpAgKq6F8C98nCFb0OfXMobJNi6Ow@mail.gmail.com> <CAHYJk3RgHN+WZs-57dOSuNJ2KQVJFEMK3GYOeXKktbvZ6ba+Ww@mail.gmail.com> <151207002253.ZM32539@torch.brasslantern.com> <CAKc7PVAiaRoVuwpaWNH5+-qnkJKRYUm+cd-5z65aEz1_EFrtkA@mail.gmail.com> <160219111327.ZM17643@torch.brasslantern.com>
On Feb 19, 11:13am, Bart Schaefer wrote:
} Subject: Re: Feature request: #a (approximate matching) only for spaces
}
} On Feb 19, 7:21am, Sebastian Gniazdowski wrote:
} }
} } Can be resulting pattern put into $parameter for later use by $~parameter?
}
} You might be able to work out a way to do so, but it'd be difficult to get
} the quoting right so that arrays were processed before joining etc.
Fiddled with this a little; here's the formulation that can be assigned
(in double quotes) to a parameter and/or used with $ary[(R)pattern]:
(${(j:|:)${i::=1}+${(@)${:-$INPUT"${(@)^${(s::)INPUT}/?/}"}:s/(#b)(#s)(?(#c$[i++]))/${match[1]}*}})*
So for example in the zsh source tree:
torch% () {
function> integer i=0
function> local INPUT=con
function> local -a files=(*) match
function> print -r --
$files[(R)(${(j:|:)~${i::=1}+${(@)${:-$INPUT"${(@)^${(s::)INPUT}/?/}"}:s/(#b)(#s)(?(#c$[i++]))/${match[1]}*}})*]
function> }
config.status
torch%
All that was really necessary was to add (@) after +${ but note that any
pattern characters in $INPUT will become active again in the subscript.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author