Skip to content

Commit c87242a

Browse files
author
Pascal Zumkehr
committed
fix parsing when string starts directly after identifier or so
1 parent 1d3982a commit c87242a

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

lib/coderay/scanners/bash.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def scan_tokens tokens, options
106106
kind = :shell
107107
elsif match = scan(PRE_CONSTANTS)
108108
kind = :pre_constant
109-
elsif match = scan(/[^\s]*[A-Za-z_][A-Za-z_0-9]*\+?=/)
109+
elsif match = scan(/[^\s'"]*[A-Za-z_][A-Za-z_0-9]*\+?=/)
110110
match =~ /(.*?)([A-Za-z_][A-Za-z_0-9]*)(\+?=)/
111111
str = $1
112112
pre = $2

test/erb_bash.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/sh
22

3+
perl -e's/to=5/to=10/' /test/file
34
echo "Parsed at <%= Time.now %>"
45
echo "Executed at `Date`"
56
command 'open quote

test/test.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ def test_0010_ErbBash
2020
[["#!/bin/sh", :directive],
2121
["\n", :end_line],
2222
["\n", :end_line],
23+
["perl", :ident],
24+
[" ", :space],
25+
["-", :operator],
26+
["e", :ident],
27+
["'s/to=5/to=10/'", :string],
28+
[" ", :space],
29+
["/", :plain],
30+
["test", :method],
31+
["/", :plain],
32+
["file", :ident],
33+
["\n", :end_line],
2334
["echo", :method],
2435
[" ", :space],
2536
[:open, :string],
@@ -61,6 +72,17 @@ def test_0011_ErbBash_Ignoring_Errors
6172
[["#!/bin/sh", :directive],
6273
["\n", :end_line],
6374
["\n", :end_line],
75+
["perl", :ident],
76+
[" ", :space],
77+
["-", :operator],
78+
["e", :ident],
79+
["'s/to=5/to=10/'", :string],
80+
[" ", :space],
81+
["/", :plain],
82+
["test", :method],
83+
["/", :plain],
84+
["file", :ident],
85+
["\n", :end_line],
6486
["echo", :method],
6587
[" ", :space],
6688
[:open, :string],

0 commit comments

Comments
 (0)