diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-09-24 22:28:49 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2007-09-24 22:28:49 +0800 |
commit | bb777a690c2f800f75b18bd56445c528348755f5 (patch) | |
tree | 5a1c9bf3b1d712ba486698d0434e1378f2b4cf01 | |
parent | [PARSER] Remove superfluous dblquote settings when ending arith (diff) | |
download | dash-bb777a690c2f800f75b18bd56445c528348755f5.tar.gz dash-bb777a690c2f800f75b18bd56445c528348755f5.zip |
[PARSER] Remove arithmetic expansion collapsing at parse time
Collapsing arithmethc 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: (4 + 5) New result: 9
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/parser.c | 22 |
2 files changed, 8 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog index e5987f9..7992485 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ * Remove superfluous arinest test in CENDQUOTE. * Remove superfluous arinest test for dqvarnest. * Remove superfluous dblquote settings when ending arith. + * Remove arithmetic expansion collapsing at parse time. 2007-09-22 Oleg Verych <olecom@flower.upol.cz> diff --git a/src/parser.c b/src/parser.c index 791251d..e00fd4b 100644 --- a/src/parser.c +++ b/src/parser.c @@ -967,11 +967,9 @@ quotemark: --parenlevel; } else { if (pgetc() == ')') { - if (--arinest == 0) { - USTPUTC(CTLENDARI, out); + USTPUTC(CTLENDARI, out); + if (!--arinest) syntax = prevsyntax; - } else - USTPUTC(')', out); } else { /* * unbalanced parens @@ -1373,18 +1371,12 @@ parsearith: { if (++arinest == 1) { prevsyntax = syntax; syntax = ARISYNTAX; - USTPUTC(CTLARI, out); - if (dblquote) - USTPUTC('"',out); - else - USTPUTC(' ',out); - } else { - /* - * we collapse embedded arithmetic expansion to - * parenthesis, which should be equivalent - */ - USTPUTC('(', out); } + USTPUTC(CTLARI, out); + if (dblquote) + USTPUTC('"',out); + else + USTPUTC(' ',out); goto parsearith_return; } |