ash: remove arithmetic expansion collapsing at parse time
authorRon Yorston <rmy@pobox.com>
Mon, 18 May 2015 07:56:16 +0000 (09:56 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 18 May 2015 07:56:16 +0000 (09:56 +0200)
commitad88bdee0c382b9f1cbbb2d76cc739afb2790a60
tree7b2975b0d5ab3465436bb9db7d4f3cf5a6732d8d
parent7e4ed267b645090fb576e1c876a88a9c73faabe9
ash: remove arithmetic expansion collapsing at parse time

Collapsing arithmetic expansion is incorrect when the inner arithmetic
expansion is a part of a parameter expansion.

Test case:
   unset a
   echo $((3 + ${a:=$((4 + 5))}))
   echo $a
Old result:
   12
   (4 + 5)
New result:
   12
   9

Based on commit bb777a6 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Herbert Xu

function                                             old     new   delta
readtoken1                                          3180    3163     -17

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c
shell/ash_test/ash-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.right [new file with mode: 0644]
shell/ash_test/ash-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.tests [new file with mode: 0755]