From 14b8d226035c2dda76e9838d0e379a21328eb0f7 Mon Sep 17 00:00:00 2001 From: Ryuichi Ueda Date: Wed, 25 Sep 2024 09:11:55 +0900 Subject: [PATCH] Fix the handling of double quotations in arith --- src/elements/expr/arithmetic/parser.rs | 5 +++-- test/ok | 1 + test/test_others.bash | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/elements/expr/arithmetic/parser.rs b/src/elements/expr/arithmetic/parser.rs index 8ef9bf27..cff93aab 100644 --- a/src/elements/expr/arithmetic/parser.rs +++ b/src/elements/expr/arithmetic/parser.rs @@ -83,9 +83,10 @@ impl ArithmeticExpr { } if word.text.starts_with("\"") && word.text.ends_with("\"") { let mut f = Feeder::new(&w); - if let Some(e) = ArithmeticExpr::parse(&mut f, core, false) { + if let Some(mut e) = ArithmeticExpr::parse(&mut f, core, false) { if e.elements.len() != 1 && f.len() == 0 { - ans.elements.push( ArithElem::InParen(e) ); + //ans.elements.push( ArithElem::InParen(e) ); + ans.elements.append( &mut e.elements ); return true; } } diff --git a/test/ok b/test/ok index bb403ea0..e4888750 100644 --- a/test/ok +++ b/test/ok @@ -4,3 +4,4 @@ ./test_compound.bash ./test_others.bash ./test_job.bash +../../../test/test_others.bash diff --git a/test/test_others.bash b/test/test_others.bash index 6f041d7c..70fca827 100755 --- a/test/test_others.bash +++ b/test/test_others.bash @@ -1072,8 +1072,8 @@ res=$($com <<< 'echo $(( -" .3" )) $(( - "- .4" ))') res=$($com <<< 'echo $(( "1 + 1" ))') [ "$res" == "2" ] || err $LINENO -res=$($com <<< 'A=1; echo $(( "1 + A" ))') -[ "$res" == "2" ] || err $LINENO +res=$($com <<< 'A=1; echo $(( "1 + A" * 3 ))') +[ "$res" == "4" ] || err $LINENO res=$($com <<< 'echo $(( "1 << 1" ))') [ "$res" == "2" ] || err $LINENO