2017-02-18 23:17:07 +03:00
|
|
|
filetype: shell
|
|
|
|
|
2021-07-21 22:44:32 +03:00
|
|
|
# Detection based on filename is rather complicated as there are many
|
|
|
|
# different file extensions and special filenames in use.
|
|
|
|
# This expressions aims to capture them all while not matching
|
|
|
|
# filenames that coincidentally contain the same substring.
|
|
|
|
#
|
|
|
|
# File extensions:
|
|
|
|
# * .sh
|
|
|
|
# * .bash
|
|
|
|
# * .ash
|
|
|
|
# * .ebuild (Gentoo ebuild format)
|
|
|
|
#
|
|
|
|
# Special filenames:
|
2021-08-07 03:44:57 +03:00
|
|
|
# * .bashrc, .bash_aliases, .bash_functions .bash_profile
|
2021-07-21 22:44:32 +03:00
|
|
|
# * profile, .profile (/etc/profile or ~/.profile)
|
|
|
|
# * Pkgfile
|
|
|
|
# * pkgmk.conf
|
|
|
|
# * rc.conf
|
|
|
|
# * PKGBUILD (Arch Linux build scripts)
|
|
|
|
# * APKBUILD
|
|
|
|
#
|
|
|
|
# Fix command (fc) files:
|
|
|
|
# * bash-fc. (followed by a random string)
|
2017-03-21 22:07:39 +03:00
|
|
|
detect:
|
2023-06-06 03:39:12 +03:00
|
|
|
filename: "(\\.(sh|bash|ash|ebuild)$|(\\.bash(rc|_aliases|_functions|_profile)|\\.?profile|Pkgfile|pkgmk\\.conf|rc\\.conf|PKGBUILD|APKBUILD)$|bash-fc\\.)"
|
2023-05-05 00:48:42 +03:00
|
|
|
signature: "^#!.*/(env +)?(ba)?(a)?(mk)?sh( |$)"
|
2017-02-18 23:17:07 +03:00
|
|
|
|
|
|
|
rules:
|
2017-03-21 22:07:39 +03:00
|
|
|
# Numbers
|
2017-02-18 23:17:07 +03:00
|
|
|
- constant.number: "\\b[0-9]+\\b"
|
2017-03-21 22:07:39 +03:00
|
|
|
# Conditionals and control flow
|
2017-02-18 23:17:07 +03:00
|
|
|
- statement: "\\b(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\\b"
|
2023-06-06 03:39:12 +03:00
|
|
|
- special: "[`$<>!=&~^\\{\\}\\(\\)\\;\\]\\[]+"
|
2017-03-21 22:07:39 +03:00
|
|
|
# Shell commands
|
2017-02-18 23:17:07 +03:00
|
|
|
- type: "\\b(cd|echo|export|let|set|umask|unset)\\b"
|
2017-03-21 22:07:39 +03:00
|
|
|
# Common linux commands
|
2017-02-18 23:17:07 +03:00
|
|
|
- type: "\\b((g|ig)?awk|bash|dash|find|\\w{0,4}grep|kill|killall|\\w{0,4}less|make|pkill|sed|sh|tar)\\b"
|
2017-03-21 22:07:39 +03:00
|
|
|
# Coreutils commands
|
2017-02-18 23:17:07 +03:00
|
|
|
- type: "\\b(base64|basename|cat|chcon|chgrp|chmod|chown|chroot|cksum|comm|cp|csplit|cut|date|dd|df|dir|dircolors|dirname|du|env|expand|expr|factor|false|fmt|fold|head|hostid|id|install|join|link|ln|logname|ls|md5sum|mkdir|mkfifo|mknod|mktemp|mv|nice|nl|nohup|nproc|numfmt|od|paste|pathchk|pinky|pr|printenv|printf|ptx|pwd|readlink|realpath|rm|rmdir|runcon|seq|(sha1|sha224|sha256|sha384|sha512)sum|shred|shuf|sleep|sort|split|stat|stdbuf|stty|sum|sync|tac|tail|tee|test|time|timeout|touch|tr|true|truncate|tsort|tty|uname|unexpand|uniq|unlink|users|vdir|wc|who|whoami|yes)\\b"
|
2017-03-21 22:07:39 +03:00
|
|
|
# Conditional flags
|
2024-03-12 23:11:20 +03:00
|
|
|
- statement: "\\s+(-[A-Za-z]+|--[a-z]+)"
|
2017-03-21 22:07:39 +03:00
|
|
|
|
2023-06-06 03:39:12 +03:00
|
|
|
- identifier: "\\$\\{[0-9A-Za-z_:!%&=+#~@*^$?, .\\-\\/\\[\\]]+\\}"
|
2023-07-11 23:49:12 +03:00
|
|
|
- identifier: "\\$[0-9A-Za-z_:!%&=+#~@*^$?,\\-\\[\\]]+"
|
2017-03-21 22:07:39 +03:00
|
|
|
|
|
|
|
- constant.string:
|
|
|
|
start: "\""
|
2017-03-28 03:53:08 +03:00
|
|
|
end: "\""
|
2017-03-29 16:45:16 +03:00
|
|
|
skip: "\\\\."
|
2023-07-11 23:49:12 +03:00
|
|
|
rules: []
|
2017-03-21 22:07:39 +03:00
|
|
|
|
|
|
|
- constant.string:
|
|
|
|
start: "'"
|
2017-03-28 03:53:08 +03:00
|
|
|
end: "'"
|
2023-07-11 23:49:12 +03:00
|
|
|
skip: "\\\\."
|
2017-03-21 22:07:39 +03:00
|
|
|
rules: []
|
|
|
|
|
2023-10-22 01:19:59 +03:00
|
|
|
- constant.string:
|
|
|
|
start: "<<[^\\s]+[-~.]*[A-Za-z0-9]+$"
|
|
|
|
end: "^[^\\s]+[A-Za-z0-9]+$"
|
|
|
|
skip: "\\\\."
|
|
|
|
rules: []
|
|
|
|
|
2017-03-21 22:07:39 +03:00
|
|
|
- comment:
|
2018-08-20 23:22:07 +03:00
|
|
|
start: "(^|\\s)#"
|
2017-03-21 22:07:39 +03:00
|
|
|
end: "$"
|
|
|
|
rules:
|
|
|
|
- todo: "(TODO|XXX|FIXME):?"
|