diff options
author | Georg Brandl <georg@python.org> | 2014-10-08 09:21:15 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-10-08 09:21:15 +0200 |
commit | 444fb6fd9b3492040a36fcca672fee8175f8d603 (patch) | |
tree | 2bd411ca78decf276b95dc6b1788e594b2e35287 /pygments/lexers/shell.py | |
parent | 491fec23ef01687906f5d71ee718522cd2917926 (diff) | |
parent | c1bfe4eed3805d3556bffa3c6b9cc2d3f6976205 (diff) | |
download | pygments-444fb6fd9b3492040a36fcca672fee8175f8d603.tar.gz |
Merged in leodemoura/pygments-main (pull request #399)
Diffstat (limited to 'pygments/lexers/shell.py')
-rw-r--r-- | pygments/lexers/shell.py | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/pygments/lexers/shell.py b/pygments/lexers/shell.py index df9b56f4..b4d81446 100644 --- a/pygments/lexers/shell.py +++ b/pygments/lexers/shell.py @@ -31,7 +31,7 @@ class BashLexer(RegexLexer): """ name = 'Bash' - aliases = ['bash', 'sh', 'ksh'] + aliases = ['bash', 'sh', 'ksh', 'shell'] filenames = ['*.sh', '*.ksh', '*.bash', '*.ebuild', '*.eclass', '.bashrc', 'bashrc', '.bash_*', 'bash_*', 'PKGBUILD'] mimetypes = ['application/x-sh', 'application/x-shellscript'] @@ -39,11 +39,15 @@ class BashLexer(RegexLexer): tokens = { 'root': [ include('basic'), - (r'\$\(\(', Keyword, 'math'), - (r'\$\(', Keyword, 'paren'), - (r'\${#?', Keyword, 'curly'), (r'`', String.Backtick, 'backticks'), include('data'), + include('interp'), + ], + 'interp': [ + (r'\$\(\(', Keyword, 'math'), + (r'\$\(', Keyword, 'paren'), + (r'\${#?', String.Interpol, 'curly'), + (r'\$#?(\w+|.)', Name.Variable), ], 'basic': [ (r'\b(if|fi|else|while|do|done|for|then|return|function|case|' @@ -65,22 +69,28 @@ class BashLexer(RegexLexer): (r'&&|\|\|', Operator), ], 'data': [ - (r'(?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double), - (r"(?s)\$?'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single), + (r'(?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\$])*"', String.Double), + (r'"', String.Double, 'string'), + (r"(?s)\$'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single), + (r"(?s)'.*?'", String.Single), (r';', Punctuation), (r'&', Punctuation), (r'\|', Punctuation), (r'\s+', Text), (r'\d+(?= |\Z)', Number), (r'[^=\s\[\]{}()$"\'`\\<&|;]+', Text), - (r'\$#?(\w+|.)', Name.Variable), (r'<', Text), ], + 'string': [ + (r'"', String.Double, '#pop'), + (r'(?s)(\\\\|\\[0-7]+|\\.|[^"\\$])+', String.Double), + include('interp'), + ], 'curly': [ - (r'}', Keyword, '#pop'), + (r'}', String.Interpol, '#pop'), (r':-', Keyword), (r'\w+', Name.Variable), - (r'[^}:"\'`$]+', Punctuation), + (r'[^}:"\'`$\\]+', Punctuation), (r':', Punctuation), include('root'), ], |