Skip to content

Commit 682f573

Browse files
zufuliunyamatongwe
authored andcommitted
#137 Treat "<<" in arithmetic contexts as left bitwise shift operator instead of here-doc.
1 parent 963430a commit 682f573

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

doc/LexillaHistory.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,10 @@ <h3>
610610
<a href="https://github.com/ScintillaOrg/lexilla/issues/154">Issue #154</a>.
611611
</li>
612612
<li>
613+
Bash: treat "&lt;&lt;" in arithmetic contexts as left bitwise shift operator instead of here-doc.
614+
<a href="https://github.com/ScintillaOrg/lexilla/issues/137">Issue #137</a>.
615+
</li>
616+
<li>
613617
Batch: style SCE_BAT_AFTER_LABEL used for rest of line after label which is not executed.
614618
<a href="https://github.com/ScintillaOrg/lexilla/issues/148">Issue #148</a>.
615619
</li>

lexers/LexBash.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ void SCI_METHOD LexerBash::Lex(Sci_PositionU startPos, Sci_Position length, int
876876
} else {
877877
continue; // scalar has no delimiter pair
878878
}
879-
} else if (sc.Match('<', '<')) {
879+
} else if (cmdState != CmdState::Arithmetic && sc.Match('<', '<')) {
880880
sc.SetState(SCE_SH_HERE_DELIM);
881881
HereDoc.State = 0;
882882
if (sc.GetRelative(2) == '-') { // <<- indent case

test/examples/bash/x.bsh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ while read -r f; do
3131
} >> $OUT_FILE
3232
done
3333

34+
# Issue 137, should be shift but here-doc was detected
35+
echo $(( x << END ))
36+
pwd
37+
END
38+
3439
INVALID_NUMBER=0#0000

test/examples/bash/x.bsh.folded

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,10 @@
3131
0 402 0 | } >> $OUT_FILE
3232
0 401 0 | done
3333
1 400 0
34+
0 400 0 # Issue 137, should be shift but here-doc was detected
35+
0 400 0 echo $(( x << END ))
36+
0 400 0 pwd
37+
0 400 0 END
38+
1 400 0
3439
0 400 0 INVALID_NUMBER=0#0000
3540
0 400 0

test/examples/bash/x.bsh.styled

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ EOF{0}
3131
{7}}{0} {7}>>{0} {9}$OUT_FILE{0}
3232
{4}done{0}
3333

34+
{2}# Issue 137, should be shift but here-doc was detected{0}
35+
{4}echo{0} {7}$(({0} {8}x{0} {7}<<{0} {8}END{0} {7})){0}
36+
{8}pwd{0}
37+
{8}END{0}
38+
3439
{8}INVALID_NUMBER{7}={1}0#0000{0}

0 commit comments

Comments
 (0)