Skip to content

Commit

Permalink
Bash: add support for hyphenated param names
Browse files Browse the repository at this point in the history
Previously, a parameter (flag) such as `curl --upload-file` would not be
properly recognized, because of the hyphen in the parameter name. This
commit causes `--upload-file` to be properly recognized as a parameter.

fixes #3569, fixes #3696
  • Loading branch information
reidmv committed Nov 3, 2023
1 parent 59e5a34 commit f20811e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/prism-bash.js
Expand Up @@ -115,7 +115,7 @@
},
// Highlight parameter names as variables
'parameter': {
pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:[.-]\w+)*(?=[=\s]|$)/,
alias: 'variable',
lookbehind: true
},
Expand Down
5 changes: 5 additions & 0 deletions tests/languages/bash/parameter_feature.test
@@ -1,5 +1,6 @@
docker run
--name elk \
--log-level info \
-p 5601:5601 \
--restart=always \
--privileged \
Expand All @@ -16,6 +17,10 @@ easyj/elk:7.12.1
" elk ",
["punctuation", "\\"],

["parameter", "--log-level"],
" info ",
["punctuation", "\\"],

["parameter", "-p"],
["number", "5601"],
":5601 ",
Expand Down

0 comments on commit f20811e

Please sign in to comment.