Some info on my configuration (I use Debian): Package: zsh Version: 4.0.6-27 Package: zsh-beta Version: 4.1.0-dev-7+cvs20030217-1 The first problem. While trying to understand other things I encountered this: Amber% export LANG=pl_PL Amber% zsh Amber% echo $[12.12/12] 1.01 Amber% <Ctrl-D pressed here> Amber% zsh Amber% echo $[12.12/12] 1,01 Comma is the locale-correct decimal separator for pl_PL. ltrace pointed me to the usage of setlocale in zzlex in math.c: prev_locale argument to setlocale(LC_NUMERIC, prev_locale); gets clobbered (differently each time); man 3 setlocale says: A successful call to setlocale() returns an opaque string that corresponds to the locale set. This string may be allocated in static storage. so I think this is probably the problem. The second problem. With LANG=pl_PL Amber% zsh-beta -f Amber% echo $[12.12/12] 1,01. Amber% echo $[12./12] 1. So the output contains an unnecessary dot at the end. NB: I know that the changelog gives a reason for the dot: * 16423: Src/params.c: Don't let convfloat output a number looking like an integer; append a `.' if necessary. Otherwise the wrong type of arithmetic will be used on numbers stored in scalars. but... ...the third (and main) problem. It will all be wrong anyway with floats-in-scalars in a localized environment. foo=$((12.12/12)) means foo=1,01 in pl_PL which means $((foo)) equiv $((1,01)) equiv $((01)) equiv 1 One solution would be locale independent arithmetic expansion, but then echo $((12.12/12)) would print unlocalized 1.01 Another simple solution is to require typeset -F foo; ((foo=12.12/12)) for repeatable results, and ignore the problem of scalars. Are there any more complicated but workable solutions? -- Michał Politowski -- mpol@xxxxxxxxxxxxxxxxxxx Warning: this is a memetically modified message
Attachment:
pgpUaUEIJKXO0.pgp
Description: PGP signature