David Lawrence Ramsey | 5e6434c | 2006-06-01 17:23:28 +0000 | [diff] [blame] | 1 | ## Here is an example for Bourne shell scripts. |
Benno Schulenberg | fe9da94 | 2014-05-16 20:21:34 +0000 | [diff] [blame] | 2 | |
David Lawrence Ramsey | 5e6434c | 2006-06-01 17:23:28 +0000 | [diff] [blame] | 3 | syntax "sh" "\.sh$" |
Benno Schulenberg | bb4edd0 | 2015-02-18 20:01:30 +0000 | [diff] [blame] | 4 | header "^#!.*((ba|da|k|pdk)?sh[-0-9_]*|openrc-run|runscript)" |
Benno Schulenberg | fe9da94 | 2014-05-16 20:21:34 +0000 | [diff] [blame] | 5 | magic "(POSIX|Bourne.*) shell script text" |
Benno Schulenberg | 3de2c70 | 2015-04-18 11:35:23 +0000 | [diff] [blame] | 6 | linter dash -n |
Mike Scalora | 6a2032f | 2016-05-25 22:13:50 +0200 | [diff] [blame] | 7 | comment "#" |
Benno Schulenberg | fe9da94 | 2014-05-16 20:21:34 +0000 | [diff] [blame] | 8 | |
David Lawrence Ramsey | 5e6434c | 2006-06-01 17:23:28 +0000 | [diff] [blame] | 9 | icolor brightgreen "^[0-9A-Z_]+\(\)" |
Benno Schulenberg | 5d5e930 | 2014-02-26 21:33:47 +0000 | [diff] [blame] | 10 | color green "\<(break|case|continue|do|done|elif|else|esac|exit|fi|for|function|if|in|read|return|select|shift|then|time|until|while)\>" |
| 11 | color green "\<(declare|eval|exec|export|let|local)\>" |
| 12 | color green "[{}():;|`$<>!=&\\]" "(\]|\[)" |
David Lawrence Ramsey | 5e6434c | 2006-06-01 17:23:28 +0000 | [diff] [blame] | 13 | color green "-[Ldefgruwx]\>" |
| 14 | color green "-(eq|ne|gt|lt|ge|le|s|n|z)\>" |
Benno Schulenberg | 5d5e930 | 2014-02-26 21:33:47 +0000 | [diff] [blame] | 15 | 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)\>" |
Benno Schulenberg | fe9da94 | 2014-05-16 20:21:34 +0000 | [diff] [blame] | 16 | |
Benno Schulenberg | 5d5e930 | 2014-02-26 21:33:47 +0000 | [diff] [blame] | 17 | # Basic variable names (no braces). |
| 18 | color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*" |
| 19 | # More complicated variable names; handles braces and replacements and arrays. |
| 20 | color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:space:]]*[[:alnum:]_]+[[:space:]]*|@)\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})" |
Benno Schulenberg | fe9da94 | 2014-05-16 20:21:34 +0000 | [diff] [blame] | 21 | |
| 22 | # Comments. |
David Lawrence Ramsey | 9368217 | 2006-06-08 12:49:57 +0000 | [diff] [blame] | 23 | color cyan "(^|[[:space:]])#.*$" |
Benno Schulenberg | fe9da94 | 2014-05-16 20:21:34 +0000 | [diff] [blame] | 24 | |
| 25 | # Strings. |
Benno Schulenberg | 5d5e930 | 2014-02-26 21:33:47 +0000 | [diff] [blame] | 26 | color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'" |
Benno Schulenberg | fe9da94 | 2014-05-16 20:21:34 +0000 | [diff] [blame] | 27 | |
| 28 | # Trailing whitespace. |
David Lawrence Ramsey | e081fb9 | 2007-04-11 22:18:16 +0000 | [diff] [blame] | 29 | color ,green "[[:space:]]+$" |