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

Numbers with leading _



I was playing with extending hasbraces+xpandbraces to allow _ in
numbers via zstrtoul_underscore, and noticed that in normal math
context, this happens:
% echo $(( _1000 ))
0
% a=(1 2 3); echo $a[_1]

% a=(1 2 3); echo $a[1_]
1

but my modifications worked fine:
% echo {_999_.._1_0_0_1_}
999 1000 1001

Obviously there's no real reason why anyone should want to specify a
number with a leading underscore but is there a reason to reject it in
the normal math context, and should we print some kind of error when
we do it rather than silently parse it as a 0?

I didn't yet try to track down where this rejection happens, but it's
at least not in zstrtoul_underscore.

-- 
Mikael Magnusson




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