Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Unexpected behavior of P parameter expansion flag inside arithmetic evaluation
- X-seq: zsh-workers 29697
- From: Nikolai Weibull <now@xxxxxxxx>
- To: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- Subject: Re: Unexpected behavior of P parameter expansion flag inside arithmetic evaluation
- Date: Wed, 17 Aug 2011 11:25:05 +0200
- Cc: Zsh Workers <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=tIoSztChFw63udx11KMVqq6RQZsMvo1ehVDJix2ISvA=; b=oqlBVC4vQom/0vLBVlOysZxDnII19X1tpoD6ErsZYvppS6Do3KV29C5BKIfg75++d6 FJl4QGMS7av7BfUcPbLhZqtb8HbZogSIuw6Eejp54oPBNSXFv8lJufqjWXUIw6gIi6xo BQRjnDL3NpEtvJ7h1a+30rnE9Einh4ojItKHs=
- In-reply-to: <20110817101730.61c5a65a@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CADdV=MvdWjJLiZxHL_jRpj8AL1fSRAjpSSpyQEWxxJ8fChNQ2g@mail.gmail.com> <20110817101730.61c5a65a@pwslap01u.europe.root.pri>
- Sender: nikolai.weibull@xxxxxxxxx
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