Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bash) Less false positives for keywords in arguments ie, --keyword-flag #2669

Merged
merged 1 commit into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Big picture:

Language Improvements:

- fix(bash) Fewer false positives for keywords in arguments (#2669) [sirosen][]
- fix(js) Prevent long series of /////// from causing freezes (#2656) [Josh Goebel][]
- enh(csharp) Add `init` and `record` keywords for C# 9.0 (#2660) [Youssef Victor][]
- enh(matlab) Add new R2019b `arguments` keyword and fix `enumeration` keyword (#2619) [Andrew Janke][]
Expand All @@ -36,6 +37,7 @@ Language Improvements:
[ezksd]: https://github.com/ezksd
[idleberg]: https://github.com/idleberg
[eytienne]: https://github.com/eytienne
[sirosen]: https://github.com/sirosen


## Version 10.1.1
Expand Down
2 changes: 1 addition & 1 deletion src/languages/bash.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default function(hljs) {
name: 'Bash',
aliases: ['sh', 'zsh'],
keywords: {
$pattern: /\b-?[a-z\._]+\b/,
$pattern: /\b-?[a-z\._-]+\b/,
keyword:
'if then else elif fi for while in do done case esac function',
literal:
Expand Down
10 changes: 10 additions & 0 deletions test/markup/bash/token-containing-keyword.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<span class="hljs-comment"># a keyword as part of an option</span>
mycmd --disable-foo

<span class="hljs-comment"># a keyword as part of a parameter</span>
some-cmd set-some-setting
some-cmd set_some_setting

<span class="hljs-comment"># a keyword as part of command</span>
check-case foo
check_case foo
10 changes: 10 additions & 0 deletions test/markup/bash/token-containing-keyword.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# a keyword as part of an option
mycmd --disable-foo

# a keyword as part of a parameter
some-cmd set-some-setting
some-cmd set_some_setting

# a keyword as part of command
check-case foo
check_case foo