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 29696
- From: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- To: Zsh Workers <zsh-workers@xxxxxxx>
- Subject: Re: Unexpected behavior of P parameter expansion flag inside arithmetic evaluation
- Date: Wed, 17 Aug 2011 10:17:30 +0100
- In-reply-to: <CADdV=MvdWjJLiZxHL_jRpj8AL1fSRAjpSSpyQEWxxJ8fChNQ2g@mail.gmail.com>
- 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
- Organization: Cambridge Silicon Radio
- References: <CADdV=MvdWjJLiZxHL_jRpj8AL1fSRAjpSSpyQEWxxJ8fChNQ2g@mail.gmail.com>
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.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
Messages sorted by:
Reverse Date,
Date,
Thread,
Author