Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/languages/bash.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ export default function(hljs) {
// to consume paths to prevent keyword matches inside them
const PATH_MODE = { match: /(\/[a-z._-]+)+/ };

// Match command-line options (short: -o, long: --option, --option=value)
// to ensure consistent highlighting across continuation lines.
const OPTION = {
className: 'attr',
begin: /(?:^|\s)--?\w[\w-]*(?:=?\S*)?\s*/,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure about flags like

--mode=compact

Think perhaps the = should be operator (or nothing) and maybe compact should be a string? Thoughts?

Might be nice to see this a few different ways. CC @allejo Any thoughts?

relevance: 0
};

// http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
const SHELL_BUILT_INS = [
"break",
Expand Down Expand Up @@ -397,6 +405,7 @@ export default function(hljs) {
COMMENT,
HERE_DOC,
PATH_MODE,
OPTION,
QUOTE_STRING,
ESCAPED_QUOTE,
APOS_STRING,
Expand Down