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

Re: suprise with -=



On Oct 18, 10:46pm, Ray Andrews wrote:
}
} That's a bit of a surprise, why is zsh fussier with '-=' than with '+='?

Outside of the (( )), -= is not an assignment operator at all, because
the default is to do either array or string assignment, and there is
no sensible way to "subtract" one array or string from another.

Conversely += is defined to mean "append", so it is a valid operator.

I'd almost call it a bug that [outside of (( )) context] first+=second
does arithmetic when $first is an integer.  It ought to be either an
error or forcibly convert $first to string and append "second".



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