Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: behavior of test true -a \( ! -a \)



> On 21/03/2024 12:18 GMT Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> On 2024-03-21 11:29:39 +0000, Peter Stephenson wrote:
> > I suppose as long as we only look for ")" when we know there's one to
> > match we can probably get away with it without being too clever.  If
> > there's a ")" that logically needs to be treated as a string following a
> > "(" we're stuck but I think that's fair game.
> > 
> > Something simple like: if we find a (, look for a matching ), so blindly
> > count intervening ('s and )'s regardless of where they occur, and then
> > NULL out the matching ) temporarily until we've parsed the expression
> > inside.  If we don't find a matching one treat the ( as as a string.
> 
> But be careful with the simple
> 
>   test \( = \)
> 
> which you may not want to change. This is currently the equality test,
> thus returning false (1).

Meh.

I think we factor out simple cases with two or three arguments and
assume they aren't doing grouping or logical combinations, so that might
be OK.  Obviously once we're into more complciated expressions it's
going to get fraught, but keeping the simple cases that test was
originally designed for (and ideally should only ever be used with)
working is a good goal.

pws




Messages sorted by: Reverse Date, Date, Thread, Author