]> git.wh0rd.org Git - nano.git/commitdiff
Improve highlighting of shell builtins, common commands, and variables.
authorBenno Schulenberg <bensberg@justemail.net>
Wed, 26 Feb 2014 21:33:47 +0000 (21:33 +0000)
committerBenno Schulenberg <bensberg@justemail.net>
Wed, 26 Feb 2014 21:33:47 +0000 (21:33 +0000)
Patch by Mike Frysinger.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4615 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
doc/syntax/sh.nanorc

index 77611a24cb595319368cd76c93b8cfafbbc281ec..ddaec8cf6a93490f73958bf62bc9c9be03e1c6af 100644 (file)
--- 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
index f5922339f98f60dc2ee7b6bee2078be23a87da85..1623d969fbb3a4bfb78b204bc6f2f16ecacd64b2 100644 (file)
@@ -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:]]+$"