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

Re: Arith parsing bug with minus after $#



On Fri, 29 May 2015 14:24:45 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On May 29, 2015 1:54 PM, "ZyX" <kp-pav@xxxxxxxxx> wrote:
> >
> > But later it explicitly says that not enclosed in single braces may only
> be names or single-character variables. I.e. $#- is ${#}-, $10 is ${1}0, …
> 
> Yes, but $#name to return the length of the value of $name is already a zsh
> extension, so unless we're in some emulation mode, treating $#- as the
> length of $- is perfectly reasonable.

Perhaps more interesting is $#*, since "*" is a much more commmon
special parameter that's also an operator, and isn't quite so horrifically
overloaded in parameter substitution.

% emulate sh -c 'fn() { echo $(( $#*3 )); }'
% fn one
13

That looks like it needs some emulation, though it can wait since nobody's
tripped over it.

I'm not agonizing much over the extremely rare and confusing $#-, to
be honest.

pws



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