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

Re: what is truth?



On 10/09/2015 09:16 PM, Kurtis Rader wrote:
On Fri, Oct 9, 2015 at 8:24 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:

test ()
{
[[ "$1" = <-> ]]  && echo true
}

I don't have a clue what to make of ' <-> '.  What value
would work?

The redirection characters "<" and ">" are apparently still interpreted as
such even within a "[[ ]]" construct. Or something very similar is
occurring. Replace the dash with "x":
Thanks Kurtis, it does seem that it's trying to interpret that as redirection. I thought there might be some strange cryptic meaning. So really then it's a test that can never be true nevertheless the parser still accepts it. Or maybe there really could be redirection in there.
You need to understand that all UNIX shells, including zsh, have extremely
ad-hoc unexpected behaviors.

I've noticed ;-) An honest comment like that saves much grief, since one might be prepared ahead of time for strange behavior. Man ... when I first got involved in this I was expecting
absolutely bulletproof perfection.  That was a long time ago.
This is a consequence of their input parsing
model coupled with dynamic options that configure them to behave more or
less like another shell. If you want more predictable and understandable
behavior you should be using languages like Python or Ruby.
Yup, but learning a shell seemed like a necessary thing.



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