Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: sh emulation POSIX non-conformances (no word splitting upon arithmetic expansion)
On 2021-04-11 20:18:05 +0100, Stephane Chazelas wrote:
> 2021-04-11 18:57:26 +0100, Stephane Chazelas:
> > Some non-POSIX conformances I can think of ATM:
> [...]
>
> Another one:
>
> $ zsh --emulate sh -c 'IFS=2; printf "<%s>\n" $((11*11))'
> <121>
>
> While POSIX (beleive it or not) requires:
>
> <1>
> <1>
>
> Again, that's one of the cases where many shells (most ash-based ones,
> pdksh, yash at least) behaved like zsh but switched for POSIX
> compliance (even though that hardly makes sense).
I disagree. I think that the fact that $((11*11)) behaves in
a way similar to parameter expansion makes more sense and is
less surprising:
$ sh -c 'foo=121; IFS=2; echo $foo $((11*11))'
1 1 1 1
$ zsh --emulate sh -c 'foo=121; IFS=2; echo $foo $((11*11))'
1 1 121
$
If something hardly makes sense, this is "IFS=2".
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author