diff options
author | Ron Yorston <rmy@pobox.com> | 2015-05-18 09:56:16 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-05-18 09:56:16 +0200 |
commit | ad88bdee0c382b9f1cbbb2d76cc739afb2790a60 (patch) | |
tree | 7b2975b0d5ab3465436bb9db7d4f3cf5a6732d8d /shell/ash_test | |
parent | 7e4ed267b645090fb576e1c876a88a9c73faabe9 (diff) | |
download | busybox-ad88bdee0c382b9f1cbbb2d76cc739afb2790a60.tar.gz |
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>
Diffstat (limited to 'shell/ash_test')
-rw-r--r-- | shell/ash_test/ash-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.right | 2 | ||||
-rwxr-xr-x | shell/ash_test/ash-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.tests | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/shell/ash_test/ash-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.right b/shell/ash_test/ash-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.right new file mode 100644 index 000000000..81a15855c --- /dev/null +++ b/shell/ash_test/ash-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.right @@ -0,0 +1,2 @@ +12 +9 diff --git a/shell/ash_test/ash-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.tests b/shell/ash_test/ash-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.tests new file mode 100755 index 000000000..e97a08a57 --- /dev/null +++ b/shell/ash_test/ash-vars/var-do-not-collapse-arithmetic-expansion-at-parse-time.tests @@ -0,0 +1,3 @@ +unset a +echo $((3 + ${a:=$((4 + 5))})) +echo $a |