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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy