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

Re: Unexpected behavior of P parameter expansion flag inside arithmetic evaluation



On Wed, Aug 17, 2011 at 11:17, Peter Stephenson
<Peter.Stephenson@xxxxxxx> wrote:
> On Wed, 17 Aug 2011 11:10:20 +0200
> Nikolai Weibull <now@xxxxxxxx> wrote:
>> % a=(abc)
>> % (( r = $#a )); echo $r
>> 1
>> % b=a
>> % (( r = ${#${(P)b}} )); echo $r
>> 3
>> % (( r = ${#${(P@)b}} )); echo $r
>> 1
>>
>> Why is the ‘@’ needed in this case?

> (( ... ))
>
> is equivalent to
>
> let "..."
>
> i.e. is in double-quoted context, so $b will interpolate $a as a
> scalar.  See the documentation on arithmetic evaluation in the zshmisc
> manual page.

Ah, sorry.

Thanks!



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