Add a patch from Josh Zenker for bash highlight - enscript - GNU Enscript
(HTM) git clone git://thinkerwim.org/enscript.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit e46b9ca4ea8517ee95c4ed403a120c7da75e7485
(DIR) parent df5c7cf3ece4845b91e4b4849cc05db1ed1c8d6c
(HTM) Author: Werner Fink <werner@suse.de>
Date: Tue, 23 Jan 2018 15:26:44 +0100
Add a patch from Josh Zenker for bash highlight
An escaped double- or single-quotation mark gets treated as the
beginning of a string, e.g.
ntp_server=`grep '^XNTPD_INITIAL_NTPDATE=' $XNTPD_CFG | awk -F\" '{print $2}'`
Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: James Cloos <cloos@jhcloos.com>
Diffstat:
M states/hl/sh.st | 33 ++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/states/hl/sh.st b/states/hl/sh.st
@@ -2,8 +2,21 @@
* Name: sh
* Description: Bourne shell programming language.
* Author: Juergen Kahrs <Juergen.Kahrs@t-online.de>
+ * Josh Zenker <josh.zenker@sig.com>
*/
+state sh_string extends Highlight
+{
+ /\\\\./ {
+ language_print ($0);
+ }
+
+ sh_string_end {
+ language_print ($0);
+ return;
+ }
+}
+
state sh extends HighlightEntry
{
/* Comments. */
@@ -14,11 +27,25 @@ state sh extends HighlightEntry
comment_face (false);
}
+ /* Ignore escaped quotation marks */
+ /\\\"/ {
+ language_print ($0);
+ }
+
+ /\\\'/ {
+ language_print ($0);
+ }
+
+ /\\\`/ {
+ language_print ($0);
+ }
+
/* String constants. */
- /\"/ {
+ /\"|'/ {
+ sh_string_end = regexp($0);
string_face (true);
language_print ($0);
- call (c_string);
+ call (sh_string);
string_face (false);
}
@@ -43,7 +70,7 @@ state sh extends HighlightEntry
/* Keywords. */
/\b(CDPATH|HOME|IFS|MAIL((CHECK)?|(PATH)?)|P(ATH|S(1|2))|SH(ACCT|ELL)|\
-break|c(ase|d|ontinue)|do(ne)?|e(cho|lse|sac|val|x(ec|it|port))|f(i|or)|\
+break|c(ase|d|ontinue)|do(ne)?|e(cho|l(if|se)|sac|val|x(ec|it|port))|f(i|or)|\
getopts|hash|i[fn]|limit|newgrp|pwd|re(ad(only)?|turn)|s(et|hift)|\
t(est|hen|imes|rap|ype)|u(limit|mask|n(limit|set))|w(ait|hile))\b/ {
keyword_face (true);