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

Re: A bug or improperly formatted script



On Sat, Feb 25, 2017 at 5:41 PM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
wrote:

> On Feb 25,  4:53pm, Jim wrote:
> }
> } So in my original email the alternate example
> }
> }  print $((${(z)${(fO)"$(dirs -v)"}[1][1]} + 1))
> }
> } was this forcing it to an array or was it a fluke?
>
> It was a fluke.  ${${$(print $'0\t~')[1]}[1]} == '0' whereas
> ${${$(print $'0\t~')[-1]}[1]} == '~' and $(( ~ + 1 )) == -2 (the
> tilde being interpreted as bitwise negation).
>
> Double-subscripting $var[1][1] yields the same byte whether $var is
> a scalar or an array, whereas $var[-1][1] does not unless the scalar
> is only a single character to begin with.
>
> You'd never have seen -2 if $HOME were not the only entry in the
> stack.  With $(dirs -lv) or with most other directories, the last char
> of the directory name would have been intepreted as a variable name
> and potentially produced even stranger results (though most like it
> would be an unset variable and thus be treated as zero, hiding the
> effect entirely).  A directory name ending in digits would have made
> things even stranger.
>

Still digesting, but I can say I learned my something new for today, so
the day wasn't wasted.  Looking forward to the patch you submitted.
I had tried the (A) flag, just in case it might work, but it didn't.
Wondered myself why it shouldn't apply in the case.

Thanks for your help.

Jim


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