summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Corbett <corbett.dav@husky.neu.edu>2016-05-25 12:59:04 -0400
committerDavid Corbett <corbett.dav@husky.neu.edu>2016-05-25 12:59:04 -0400
commit893b2a980a4a0295214f5ec7eeb6f414daeadc51 (patch)
treeb14d4c4bcadf2975a08df57170f6249d51cebe33
parent068a5ff1943cd0d676ed446e39b32ac5105b79df (diff)
downloadpygments-893b2a980a4a0295214f5ec7eeb6f414daeadc51.tar.gz
Fix Batch variables in FOR loop commands
-rw-r--r--pygments/lexers/shell.py4
-rw-r--r--tests/examplefiles/example.bat2
2 files changed, 4 insertions, 2 deletions
diff --git a/pygments/lexers/shell.py b/pygments/lexers/shell.py
index ad2e2d7a..c2f54fc2 100644
--- a/pygments/lexers/shell.py
+++ b/pygments/lexers/shell.py
@@ -452,9 +452,9 @@ class BatchLexer(RegexLexer):
bygroups(String.Double, using(this, state='string'), Text,
Punctuation)),
(r'"', String.Double, ('#pop', 'for2', 'string')),
- (r"('(?:%s|[\w\W])*?')([%s%s]*)(\))" % (_variable, _nl, _ws),
+ (r"('(?:%%%%|%s|[\w\W])*?')([%s%s]*)(\))" % (_variable, _nl, _ws),
bygroups(using(this, state='sqstring'), Text, Punctuation)),
- (r'(`(?:%s|[\w\W])*?`)([%s%s]*)(\))' % (_variable, _nl, _ws),
+ (r'(`(?:%%%%|%s|[\w\W])*?`)([%s%s]*)(\))' % (_variable, _nl, _ws),
bygroups(using(this, state='bqstring'), Text, Punctuation)),
include('for2')
],
diff --git a/tests/examplefiles/example.bat b/tests/examplefiles/example.bat
index 596f65de..2b45d2bc 100644
--- a/tests/examplefiles/example.bat
+++ b/tests/examplefiles/example.bat
@@ -205,5 +205,7 @@ for /f "tokens=2 delims==" %%G in ( 'assoc %+;/p extension'),%'
) &>nul ver
if errorlevel 0 if not errorlevel 1 set /a _passed+=1
goto :eof
+FOR /F %%a IN ('%%c%%') DO %%a
+rem %x% %x% %x% %x% %x% %x% %x% %x% %x% %x% %x% %x% %x% %x% %x% %x%
:/?
goto :fail