From 5d5e930aa9cc91fa0303b4474b9444637863a953 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Wed, 26 Feb 2014 21:33:47 +0000
Subject: [PATCH] Improve highlighting of shell builtins, common commands, and
 variables. Patch by Mike Frysinger.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4615 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog            |  5 +++++
 doc/syntax/sh.nanorc | 15 +++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 77611a24..ddaec8cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-02-26  Mike Frysinger  <vapier@gentoo.org>
+	* doc/syntax/sh.nanorc - Highlight more shell builtins and
+	common commands, and rewrite the variable highlighting to be
+	more exact and handle cases where string operations are used.
+
 2014-02-26  Benno Schulenberg  <bensberg@justemail.net>
 	* src/global.c (shortcut_init) -  Put PageUp and PageDown
 	and also WhereIs and WhereIsNext together in the help lines
diff --git a/doc/syntax/sh.nanorc b/doc/syntax/sh.nanorc
index f5922339..1623d969 100644
--- a/doc/syntax/sh.nanorc
+++ b/doc/syntax/sh.nanorc
@@ -4,13 +4,16 @@ syntax "sh" "\.sh$"
 magic "(POSIX|Bourne.*) shell script text"
 header "^#!.*/(ba|k|pdk)?sh[-0-9_]*"
 icolor brightgreen "^[0-9A-Z_]+\(\)"
-color green "\<(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\>"
-color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
+color green "\<(break|case|continue|do|done|elif|else|esac|exit|fi|for|function|if|in|read|return|select|shift|then|time|until|while)\>"
+color green "\<(declare|eval|exec|export|let|local)\>"
+color green "[{}():;|`$<>!=&\\]" "(\]|\[)"
 color green "-[Ldefgruwx]\>"
 color green "-(eq|ne|gt|lt|ge|le|s|n|z)\>"
-color brightblue "\<(cat|cd|chmod|chown|cp|echo|env|export|grep|install|let|ln|make|mkdir|mv|rm|sed|set|tar|touch|umask|unset)\>"
-color brightyellow ""(\\.|[^"])*""
-icolor brightred "\$\{?[0-9A-Z_!@#$*?-]+\}?"
-color brightyellow "'(\\.|[^'])*'"
+color brightblue "\<(awk|cat|cd|ch(grp|mod|own)|cp|echo|env|grep|install|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|umask|unset)\>"
+# Basic variable names (no braces).
+color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
+# More complicated variable names; handles braces and replacements and arrays.
+color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:space:]]*[[:alnum:]_]+[[:space:]]*|@)\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
 color cyan "(^|[[:space:]])#.*$"
+color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
 color ,green "[[:space:]]+$"
-- 
GitLab