Skip to content

Commit

Permalink
Fix the handling of double quotations in arith
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuichiueda committed Sep 25, 2024
1 parent c15e264 commit 14b8d22
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/elements/expr/arithmetic/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
1 change: 1 addition & 0 deletions test/ok
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
./test_compound.bash
./test_others.bash
./test_job.bash
../../../test/test_others.bash
4 changes: 2 additions & 2 deletions test/test_others.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 14b8d22

Please sign in to comment.