Bug 119952 - Bash Script highlighting fails after <<-HereDocument
Summary: Bash Script highlighting fails after <<-HereDocument
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 109031 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-01-12 04:42 UTC by Daniel Elias
Modified: 2006-02-26 00:08 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
A proposed patch to bug 119952: (33.34 KB, patch)
2006-01-12 04:57 UTC, Daniel Elias
Details
Fix for HereDoc syntax highlighting (1.55 KB, patch)
2006-02-18 18:01 UTC, Jaison Lee
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Elias 2006-01-12 04:42:47 UTC
Version:            (using KDE KDE 3.4.2)
Installed from:    Fedora RPMs
Compiler:          gcc 4.0.0 20050519 (Red Hat 4.0.0-8) 
OS:                Linux

Problem: Bash Script highlighting stops working after we use redirection like "<<-word [here-documente] delimiter".

Cause (may I dare?): a blank space is lacking in lines 767 to 770 on "bash.xml", after 'String="(&lt;&lt;-'.
What I mean is that: 'String="(&lt;&lt;-\s*'(&word;)' should be 'String="(&lt;&lt;- \s*'(&word;)'.
Comment 1 Thiago Macieira 2006-01-12 04:49:07 UTC
Can you attach a patch for this fix?
Comment 2 Daniel Elias 2006-01-12 04:57:31 UTC
Created attachment 14221 [details]
A proposed patch to bug 119952:

I have tested it in KDE 3.4.2 (Fedora Core 4), and it seams to work fine.
Comment 3 Anders Lund 2006-01-12 13:40:11 UTC
On Thursday 12 January 2006 04:42, Daniel Elias wrote:
> Cause (may I dare?): a blank space is lacking in lines 767 to 770 on
> "bash.xml", after 'String="(&lt;&lt;-'. What I mean is that:
> 'String="(&lt;&lt;-\s*'(&word;)' should be 'String="(&lt;&lt;-
> \s*'(&word;)'.


If you want to specify '1 or more space characters' instead of '0 or more 
space characters' use \s+ instead of \s*

Is at least one space required?

-anders
Comment 4 Daniel Elias 2006-01-12 18:44:32 UTC
Thiago / Anders

As it is my first time reporting a bug, perhaps I have not made myself clear (or incurred in "excessive summarization"). I apologize.

Please refer to the attached diff: diff_bash_xml.xml.
(diff /usr/share/apps/katepart/syntax/bash.xml
~/.kde/share/apps/katepart/syntax/bash.xml)

Without the inserted spaces, highlighting will stop working after the first line of  the following excerpt of bash script.

	pftp -niv $REMOTE_HOST <<-ftpcmds
	user $REMOTE_LOGIN $REMOTE_PASSWORD
	cd $REMOTE_DIR
	mput $1
	bye
	ftpcmds

That is because "highlighter" expects the here document to end with "-ftpcmds" instead of "ftpcmds". (If you do this, highlighting restart working and - obviously - the script stops. Not a big deal...)

Thanks for your interest.


Thiago Macieira wrote:
[bugs.kde.org quoted mail]
767,770c767,770
< 	<RegExpr attribute="Redirection" context="HereDocIQ"  String="(&lt;&lt;-\s*&quot;(&word;)&quot;)" lookAhead="true" />
< 	<RegExpr attribute="Redirection" context="HereDocIQ"  String="(&lt;&lt;-\s*'(&word;)')" lookAhead="true" />
< 	<RegExpr attribute="Redirection" context="HereDocIQ"  String="(&lt;&lt;-\s*\\(&word;))" lookAhead="true" />
< 	<RegExpr attribute="Redirection" context="HereDocINQ" String="(&lt;&lt;-\s*(&word;))" lookAhead="true" />
---
> 	<RegExpr attribute="Redirection" context="HereDocIQ"  String="(&lt;&lt;- \s*&quot;(&word;)&quot;)" lookAhead="true" />
> 	<RegExpr attribute="Redirection" context="HereDocIQ"  String="(&lt;&lt;- \s*'(&word;)')" lookAhead="true" />
> 	<RegExpr attribute="Redirection" context="HereDocIQ"  String="(&lt;&lt;- \s*\\(&word;))" lookAhead="true" />
> 	<RegExpr attribute="Redirection" context="HereDocINQ" String="(&lt;&lt;- \s*(&word;))" lookAhead="true" />

Comment 5 Daniel Elias 2006-02-08 14:39:46 UTC
Sorry. I have made a mistake. The bug exists but the proposed solution is not a solution. I've messed it up.
Comment 6 Jaison Lee 2006-02-18 16:57:06 UTC
Confirmed that this still exists. Reopening.
Comment 7 Jaison Lee 2006-02-18 18:01:04 UTC
Created attachment 14754 [details]
Fix for HereDoc syntax highlighting

OK. I think I've got it. I tested this against several styles of heredoc. I'll
wait a few days before I commit this, to see if anyone can verify that this
works for them, and also to make sure none of the Kate developers have
objections. This patch applies DIRECTLY to the bash.xml from 3.5.1 tree.
Comment 8 Anders Lund 2006-02-18 18:24:02 UTC
On Saturday 18 February 2006 18:01, Jaison Lee wrote:
> I'll wait a few days before I commit this, to see if anyone can verify that
> this works for them, and also to make sure none of the Kate developers have
> objections. This patch applies DIRECTLY to the bash.xml from 3.5.1 tree.


I can't see why the negative lookahead for '-' is necessary if the delimiter 
word is quoted. So my bet is that only the last line needs to be changed.

-anders
Comment 9 Jaison Lee 2006-02-18 21:59:01 UTC
> So my bet is that only the last line needs to be changed.

Good bet. :)  Only the last line appears to be necessary. 
Comment 10 Jaison Lee 2006-02-21 04:10:35 UTC
SVN commit 511851 by jlee:

BUG:119952
Bash <<- format heredoc now highlights correctly.



 M  +1 -1      bash.xml  


--- trunk/KDE/kdelibs/kate/data/bash.xml #511850:511851
@@ -763,7 +763,7 @@
 	<RegExpr attribute="Redirection" context="HereDocQ"   String="(&lt;&lt;\s*&quot;(&word;)&quot;)" lookAhead="true" />
 	<RegExpr attribute="Redirection" context="HereDocQ"   String="(&lt;&lt;\s*'(&word;)')" lookAhead="true" />
 	<RegExpr attribute="Redirection" context="HereDocQ"   String="(&lt;&lt;\s*\\(&word;))" lookAhead="true" />
-	<RegExpr attribute="Redirection" context="HereDocNQ"  String="(&lt;&lt;\s*(&word;))" lookAhead="true" />
+	<RegExpr attribute="Redirection" context="HereDocNQ"  String="(&lt;&lt;(?!-)\s*(&word;))" lookAhead="true" />
 	<RegExpr attribute="Redirection" context="HereDocIQ"  String="(&lt;&lt;-\s*&quot;(&word;)&quot;)" lookAhead="true" />
 	<RegExpr attribute="Redirection" context="HereDocIQ"  String="(&lt;&lt;-\s*'(&word;)')" lookAhead="true" />
 	<RegExpr attribute="Redirection" context="HereDocIQ"  String="(&lt;&lt;-\s*\\(&word;))" lookAhead="true" />
Comment 11 Jaison Lee 2006-02-21 04:12:47 UTC
SVN commit 511853 by jlee:

CCBUG:119952
Backported bug fix: Bash <<- format heredoc now highlights correctly.



 M  +1 -1      bash.xml  


--- branches/KDE/3.5/kdelibs/kate/data/bash.xml #511852:511853
@@ -763,7 +763,7 @@
 	<RegExpr attribute="Redirection" context="HereDocQ"   String="(&lt;&lt;\s*&quot;(&word;)&quot;)" lookAhead="true" />
 	<RegExpr attribute="Redirection" context="HereDocQ"   String="(&lt;&lt;\s*'(&word;)')" lookAhead="true" />
 	<RegExpr attribute="Redirection" context="HereDocQ"   String="(&lt;&lt;\s*\\(&word;))" lookAhead="true" />
-	<RegExpr attribute="Redirection" context="HereDocNQ"  String="(&lt;&lt;\s*(&word;))" lookAhead="true" />
+	<RegExpr attribute="Redirection" context="HereDocNQ"  String="(&lt;&lt;(?!-)\s*(&word;))" lookAhead="true" />
 	<RegExpr attribute="Redirection" context="HereDocIQ"  String="(&lt;&lt;-\s*&quot;(&word;)&quot;)" lookAhead="true" />
 	<RegExpr attribute="Redirection" context="HereDocIQ"  String="(&lt;&lt;-\s*'(&word;)')" lookAhead="true" />
 	<RegExpr attribute="Redirection" context="HereDocIQ"  String="(&lt;&lt;-\s*\\(&word;))" lookAhead="true" />
Comment 12 Daniel Elias 2006-02-21 16:06:56 UTC
It works perfectly now.
Nice job!
Comment 13 Jaison Lee 2006-02-26 00:08:54 UTC
*** Bug 109031 has been marked as a duplicate of this bug. ***