Skip to content

Commit ef98102

Browse files
committed
Fix
1 parent 14b8d22 commit ef98102

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

src/elements/expr/arithmetic/parser.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,16 @@ impl ArithmeticExpr {
8484
if word.text.starts_with("\"") && word.text.ends_with("\"") {
8585
let mut f = Feeder::new(&w);
8686
if let Some(mut e) = ArithmeticExpr::parse(&mut f, core, false) {
87-
if e.elements.len() != 1 && f.len() == 0 {
88-
//ans.elements.push( ArithElem::InParen(e) );
89-
ans.elements.append( &mut e.elements );
90-
return true;
87+
if f.len() == 0 {
88+
if e.elements.len() != 1 {
89+
ans.elements.append( &mut e.elements );
90+
return true;
91+
}
92+
93+
match &e.elements[0] {
94+
ArithElem::Word(w, _) => word = w.clone(),
95+
_ => {},
96+
}
9197
}
9298
}
9399
}

src/elements/expr/error

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@
1414
../../../test/test_others.bash
1515
../../../test/test_others.bash
1616
../../../test/test_others.bash
17+
../../../test/test_others.bash
18+
../../../test/test_others.bash
19+
../../../test/test_others.bash
20+
../../../test/test_others.bash
21+
../../../test/test_others.bash

test/error

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
../../../test/test_others.bash
2+
../../../test/test_others.bash
3+
../../../test/test_others.bash
4+
../../../test/test_others.bash
5+
../../../test/test_others.bash

test/ok

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
./test_others.bash
66
./test_job.bash
77
../../../test/test_others.bash
8+
../../../test/test_others.bash

test/test_others.bash

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,14 @@ res=$($com <<< 'A=1; echo $(("A"++ )); echo $A')
612612
[ "$res" == "1
613613
2" ] || err $LINENO
614614

615+
res=$($com <<< 'A=1; echo $(("A "++ )); echo $A')
616+
[ "$res" == "1
617+
2" ] || err $LINENO
618+
619+
res=$($com <<< 'A=1; echo $((" A"++ )); echo $A')
620+
[ "$res" == "1
621+
2" ] || err $LINENO
622+
615623
res=$($com <<< 'A=1; echo $((++"A" )); echo $A')
616624
[ "$res" == "2
617625
2" ] || err $LINENO

0 commit comments

Comments
 (0)