[go: up one dir, main page]

Menu

#118 Windows Batch file highlighting errors (and one fix)

colorer-take5
closed-fixed
HRC codes (39)
5
2007-02-06
2007-01-28
No

I discovered that the echo'ed part of an echo statement line wasn't highlighted anymore like it should if the case of "echo" changed. The following patch eliminates this problem:

--- batch.hrc Sun Jan 28 04:13:04 2007
+++ batch_new.hrc Sun Jan 28 04:14:52 2007
@@ -55,7 +55,7 @@
<!-- ECHO command -->
<!--regexp match="/\b(echo)((\s*?on\s*?(>|$))|(\s*?off\s*?(>|$)))/i" region1="Keywords" region2="Keywords" -->
<regexp match="/\becho(\s*on\s*|\s*?off\s*)/i" region0="ntCmd"/>
- <block start="/\becho\M\W/" end="/$/" scheme="Comment" region="ntStr" region00="ntCmd"/>
+ <block start="/\becho\M\W/i" end="/$/" scheme="Comment" region="ntStr" region00="ntCmd"/>
<!-- GOTO command -->
<regexp match="/(goto\s)+(\w*\b)/i" region1="ntCmd" region2="ntLabel"/>
<block start="/^\s*(\@)/" end="/$/" scheme="Batch" region="ntComment" region01="ntSpec"/>

Another issue I won't dare fixing on my own is that in a line like this:

SET GenerateDate=FOR /F "usebackq tokens=2" %%a IN (`ECHO %DATE%`) DO SET CurDate=%%a

the highlighting started from behind echo spans until the end of the line, though it should terminate in this context at the closing `. (And since you can use for /f (without the option usebackq) with ' instead of ` with the same effect this might require another rule as well.

Another issue are calls to subroutines. Those are written like this:

:mySub
echo Hey, I got a param: %1
goto :EOF

and can be called via

call :mySub param1 param2 ...

In this case the :mySub is not being highlighted as it would be the case with

goto mySub

I don't know whether there is actually a need to go into greater highlighting detail there but it'd be nice to see it done :)

Discussion

  • Igor Russkih

    Igor Russkih - 2007-01-29
    • labels: --> HRC codes
    • milestone: --> colorer-take5
    • assigned_to: nobody --> lomecb
    • status: open --> open-accepted
     
  • Igor Russkih

    Igor Russkih - 2007-01-29

    Logged In: YES
    user_id=313042
    Originator: NO

    Ok, quite deep syntax for such a simple BAT, but I'll try to review and fix them.

    Thanks.

     
  • Igor Russkih

    Igor Russkih - 2007-02-06
    • status: open-accepted --> closed-fixed
     
  • Igor Russkih

    Igor Russkih - 2007-02-06

    Logged In: YES
    user_id=313042
    Originator: NO

    tried to implement trivial changes, could be useful.

    revision 902.

     

Log in to post a comment.