Skip to content

Commit e4ad22a

Browse files
author
Harry Marr
authored
Bash: Accept hyphens in function names (#2832)
1 parent 772d42b commit e4ad22a

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

components/prism-bash.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@
8383
// but not “foo {”
8484
{
8585
// a) and c)
86-
pattern: /(\bfunction\s+)\w+(?=(?:\s*\(?:\s*\))?\s*\{)/,
86+
pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
8787
lookbehind: true,
8888
alias: 'function'
8989
},
9090
{
9191
// b)
92-
pattern: /\b\w+(?=\s*\(\s*\)\s*\{)/,
92+
pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
9393
alias: 'function'
9494
}
9595
],

components/prism-bash.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/bash/function-name_feature.test

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
function foo { :; }
2+
function foo-bar { :; }
23
bar() { :; }
34
function foo() { :; }
45
# Not a function:
@@ -13,6 +14,12 @@ bar { :; }
1314
["builtin", ":"],
1415
["punctuation", ";"],
1516
["punctuation", "}"],
17+
["keyword", "function"],
18+
["function-name", "foo-bar"],
19+
["punctuation", "{"],
20+
["builtin", ":"],
21+
["punctuation", ";"],
22+
["punctuation", "}"],
1623
["function-name", "bar"],
1724
["punctuation", "("],
1825
["punctuation", ")"],

0 commit comments

Comments
 (0)