summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-04-22 10:16:28 +0200
committerGeorg Brandl <georg@python.org>2014-04-22 10:16:28 +0200
commitff18c358cca16f8891cf9897753c156782ce5462 (patch)
tree02b049ef36ed472efce54366692ae37e946aa929
parent32004b6bdf8c0b82de6606e7610477c01fa38877 (diff)
parent676b1bd95c9b2362686fb0c623c4ffb84aac7e38 (diff)
downloadpygments-ff18c358cca16f8891cf9897753c156782ce5462.tar.gz
Merged in jaingaurav2/pygments-main-898 (pull request #332)
Improvements to bash lexing of numbers with base syntax
-rw-r--r--pygments/lexers/shell.py4
-rw-r--r--tests/examplefiles/example.sh22
2 files changed, 25 insertions, 1 deletions
diff --git a/pygments/lexers/shell.py b/pygments/lexers/shell.py
index b069b375..c07ff6ee 100644
--- a/pygments/lexers/shell.py
+++ b/pygments/lexers/shell.py
@@ -71,8 +71,8 @@ class BashLexer(RegexLexer):
(r'&', Punctuation),
(r'\|', Punctuation),
(r'\s+', Text),
- (r'[^=\s\[\]{}()$"\'`\\<&|;]+', Text),
(r'\d+(?= |\Z)', Number),
+ (r'[^=\s\[\]{}()$"\'`\\<&|;]+', Text),
(r'\$#?(\w+|.)', Name.Variable),
(r'<', Text),
],
@@ -91,6 +91,8 @@ class BashLexer(RegexLexer):
'math': [
(r'\)\)', Keyword, '#pop'),
(r'[-+*/%^|&]|\*\*|\|\|', Operator),
+ (r'\d+#\d+', Number),
+ (r'\d+#(?! )', Number),
(r'\d+', Number),
include('root'),
],
diff --git a/tests/examplefiles/example.sh b/tests/examplefiles/example.sh
new file mode 100644
index 00000000..2112cdd1
--- /dev/null
+++ b/tests/examplefiles/example.sh
@@ -0,0 +1,22 @@
+#!/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