Re: alternation option end of string

Ray Andrews <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user
Message-ID <[email protected]>

On 2026-05-03 11:45, Bart Schaefer wrote:
> On Sun, May 3, 2026 at 6:56 AM Ray Andrews <[email protected]> wrote:
>> It might not actually be the '$' just some mechanism for matching a
>> string that must end after some substring.
> That's not what you're asking for, tho.  You're asking for the entire
> string to fail to match if there's anything after the substring, but
> in the same pattern you want the substring itself to match so you can
> extract it.  You can't simultaneously have a failure and a success.
> That's why Roman's solution has (compare && out=success ||
> out=failure) -- there's no single pattern expression that can do both
> branches.  (There might be a perl expression that works, but I'm not
> confident pcre is perl-ish enough to do it.)
I thought the thing was logically possible because it can be 
articulated: 'cat' then either nothing || an 's' which can itself be 
followed by anything.  But if it's not doable, as I said, no matter cuz 
the functionality is there and I'd do it Roman's way anyway cuz it's 
self-explanatory.  Too much terseness already, so I wish for more 
terseness very lightly.  Sorta like a while back I was wondering if:
(( x > 5 )) && x=5
... had a more compact syntax -- if not so what, it's not a problem, 
still, sometimes zsh offers these little shortcuts.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.