544351f3be
In many places a carriage return is not valid whitespace and should thus not be colored as such. In some of these places a vertical tab or form feed is maybe valid whitespace, but it would be ugly or even wrong to color them because they are not part of the subsequent comment or keyword. This fixes https://savannah.gnu.org/bugs/?60456.
40 строки
1.5 KiB
Plaintext
40 строки
1.5 KiB
Plaintext
## Syntax highlighting for Bourne shell scripts.
|
|
|
|
syntax sh "(\.sh|(\.|/)(a|ba|c|da|k|mk|pdk|tc|z)sh(rc|_profile)?|/(etc/|\.)profile)$"
|
|
header "^#!.*/((env[[:blank:]]+)?((a|ba|c|da|k|mk|pdk|tc|z)?sh)|busybox[[:blank:]]+sh|openrc-run|runscript)\>"
|
|
header "-\*-.*shell-script.*-\*-"
|
|
magic "(POSIX|Bourne-Again) shell script.*text"
|
|
comment "#"
|
|
|
|
linter dash -n
|
|
|
|
# Function declarations.
|
|
color brightgreen "^[A-Za-z0-9_-]+\(\)"
|
|
|
|
# Keywords, symbols, and comparisons.
|
|
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 "-(eq|ne|gt|lt|ge|le|ef|ot|nt)\>"
|
|
|
|
# Short and long options.
|
|
color brightmagenta "[[:blank:]]-[A-Za-z]\>" "[[:blank:]]--[A-Za-z-]+\>"
|
|
|
|
# Common commands.
|
|
color brightblue "\<(awk|cat|cd|ch(grp|mod|own)|cp|cut|echo|env|grep|head|install|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|sort|tail|tar|touch|umask|unset)\>"
|
|
color normal "[.-]tar\>"
|
|
|
|
# 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:]_]*)(\[([[:blank:]]*[[:alnum:]_]+[[:blank:]]*|@)\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
|
|
|
|
# Comments.
|
|
color cyan "(^|[[:blank:]])#.*"
|
|
|
|
# Strings.
|
|
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
|
|
|
|
# Trailing whitespace.
|
|
color ,green "[[:space:]]+$"
|