Skip to content

shell/bash: Add bitwise operators to arithmetic substitution #2128

@nosoxon

Description

@nosoxon

Name of the lexer
shell

Code sample

#!/bin/bash

v=(0xEF 0xBE 0xAD 0xDE)
w=$((v[3] << 24 | v[2] << 16 | v[1] << 8 | v[0]))

echo "this is a message"
xyz() {
	# this is a function
	printf '0x%08X\n' $w
}

xyz

exit 0

Image

Fix

diff --git a/lib/rouge/lexers/shell.rb b/lib/rouge/lexers/shell.rb
index 3704066a..f2503545 100644
--- a/lib/rouge/lexers/shell.rb
+++ b/lib/rouge/lexers/shell.rb
@@ -163,7 +163,7 @@ module Rouge
 
       state :math do
         rule %r/\)\)/, Keyword, :pop!
-        rule %r([-+*/%^|&!]|\*\*|\|\|), Operator
+        rule %r([-+*/%^|&!]|\*\*|\|\||<<|>>), Operator
         rule %r/\d+(#\w+)?/, Num
         mixin :root
       end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfix-requestA request for a bugfix to be developed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions