Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: trailing components
- X-seq: zsh-workers 44425
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: PATCH: trailing components
- Date: Tue, 18 Jun 2019 16:45:51 +0200
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=MAoXsZEbRXUQA3f0zbjpY3EvriNuItYNEzEzfwLUtEM=; b=CQd98uZXwSjeRBcPCb0UBWydmEosxBeaQWg1ImLtIo631vXY38tREr2IJS4BvXgPwm 28MHBfKqtpJ0iOAuOrzd0yV7dcJLzEs1Z6M/Xd4K2Img2vA6nPH9TLP6fP1H5FIKm8eF J0Pj2PaAyhKdmyQl6kmY0Ti9qJyrLhzJnS3OvNKdU8T4qHWK8R+2nIjyUVDr4Jguiu40 Rn1dNqz5DN2A7+MEb6BpBLGWokYNbRuZvQZvZKzpwtvO7hlofWAkB2uLDbDNkol7vjgv cPYmmdiKPci7DvV+fMA8xoIyhM/tDd/0MhIFsb1SJ6IXHWg+4dBBNDcnJ2NX0xMgYCUs CyLg==
- In-reply-to: <1560866087.7731.18.camel@samsung.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>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20190618130008eucas1p176cc19c1c8b831fc30b4bf7b3294f3af@eucas1p1.samsung.com> <1560862806.7731.11.camel@samsung.com> <523ba6f0-651a-444a-8ceb-c7c4ec186b20@www.fastmail.com> <1560866087.7731.18.camel@samsung.com>
On 6/18/19, Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> On Tue, 2019-06-18 at 13:37 +0000, Daniel Shahaf wrote:
>> Peter Stephenson wrote on Tue, 18 Jun 2019 13:01 +00:00:
>> >
>> > I needed to preserve a number of trailing components of a path (other
>> > than one) and couldn't think of an easy way of doing it. Rather than
>> > craft obscure pattern substitutions, or use an ad-hoc expression to
>> > strip the prefix, I came up with a patch to add an optional number
>> > after
>> > the "t" in history style modifiers to do this. I put it after rather
>> > than before because history-style colon expressions are quite sensitive
>> > to what the first character is after the colon.
>> >
>> > Before I come up with tests and fix up the ensuing failures, you can
>> > let
>> > me know if there's a better way of doing this to save me the trouble.
>> Here are some alternatives, but I'm not claiming any of them is better
>> than «${foo:t2}»:
>
> Thanks, it's useful to know other people's thinking for comparison ---
> to be clear, what I was hoping for and lacking was something along the
> lines of:
>
> echo /blah/blah/blah/**/*.oogabooga(<stuff-here>)
>
> even if <stuff-here> wasn't quite as short as :t2. I could live with a
> few more characters but a loop or complicated substitution would lead me
> to propose adding the new code instead.
The only complaint I could imagine here (but I'm not making it) is
that this breaks
echo $foo:t42
to echo the last path segment followed by the string 42
Would it be possible to limit the new syntax to *(:t42) and ${foo:t42}
where previously the 34 is invalid (or at least silently ignored)? If
it is I think it would be nice to do so, but I'm not going to object
if it goes in as is. It's certainly nicer than the expressions
suggested earlier in the thread.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author