1. Georg Brandl
  2. pygments-main

Commits

Georg Brandl  committed 76dfc21 Merge

Merged in jaingaurav2/pygments-main-898 (pull request #332)

Improvements to bash lexing of numbers with base syntax

  • Participants
  • Parent commits 9798579, 7c724a6
  • Branches default

Comments (0)

Files changed (2)

File pygments/lexers/shell.py

View file
  • Ignore whitespace
             (r'&', Punctuation),
             (r'\|', Punctuation),
             (r'\s+', Text),
+            (r'\d+(?= |\Z)', Number),
             (r'[^=\s\[\]{}()$"\'`\\<&|;]+', Text),
-            (r'\d+(?= |\Z)', Number),
             (r'\$#?(\w+|.)', Name.Variable),
             (r'<', Text),
         ],
         'math': [
             (r'\)\)', Keyword, '#pop'),
             (r'[-+*/%^|&]|\*\*|\|\|', Operator),
+            (r'\d+#\d+', Number),
+            (r'\d+#(?! )', Number),
             (r'\d+', Number),
             include('root'),
         ],

File tests/examplefiles/example.sh

View file
  • Ignore whitespace
+#!/bin/bash
+
+printf "%d %s\n" 10 "foo"
+printf "%d %s\n" $((10#1)) "bar"
+
+let "m = 10#${1:1:2}"
+echo $m
+
+m=$((10#${1:4:3} + 10#${1:1:3}))
+echo $m
+
+m=$((10#${1:4:3}))
+echo $m
+
+m=$((10#$1))
+echo $m
+
+m=$((10#1))
+echo $m
+
+m=$((10))
+echo $m