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

Re: two mysteries

On 11/07/2015 01:55 AM, Bart Schaefer wrote:
My only guess is that in some cases the assignment occurs before the

torch% START_IDX=1+((idx-1)/page_hight)*page_hight
torch% print ${(t)START_IDX}
torch% integer START_IDX
zsh: division by zero
torch% print ${(t)START_IDX}

The value currently in the scalar $START_IDX is evaluated when the type
changes to integer, which causes the division by zero.

I think you bagged it. The type is changed *even* when the assignment fails, that didn't even occur to me. And yes, the logic is sound--it *has* to be an integer for 'division by zero' to be a relevant message. I think where I went off the rails is that this was part of my trying to pass arrays (as we discussed) rather than flocks of independent values, and whereas I had at one time:

    integer page_hight

this became:


... and (so far) I don't know how to typeset an element of an array so it was a bloody scalar and became an integer even when it failed to be assigned--so tweedle-dum was in fact tweedle-dee and I had the right issue but the bassackwards interpretation. And, as the clouds part, I now think I know how I fixed it:


    files[page_hight]=$(( files_frame[page_hight] ))

... because when I forced it to be integer all the arithmetic ducks lined up ... or something very much like that. It's actually a long chain of arithmetics, but I'll be primed for this next time something like that happens. I'm hunting ducks holding my shotgun backwards. Geez, I wish we had in inviolable integer.

} Didn't I read that
} there's a difference between 'typeset -i' and 'integer'?

Read where ...?  Doc:

I dunno, I just vaguely recall something, thought I'd ask. Something in 1st Peter, I think--some subtlety ... nevermind.

Masterful, Sensei.

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