Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Numbers with leading _
- X-seq: zsh-workers 51015
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Numbers with leading _
- Date: Mon, 21 Nov 2022 17:22:17 +0100
- Archived-at: <https://zsh.org/workers/51015>
- List-id: <zsh-workers.zsh.org>
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