1 | 1 | simandl | <?php |
2 | | | /************************************************************************************* |
3 | | | * bash.php |
4 | | | * -------- |
5 | | | * Author: Andreas Gohr (andi@splitbrain.org) |
6 | | | * Copyright: (c) 2004 Andreas Gohr, Nigel McNie (http://qbnz.com/highlighter) |
7 | 3 | simandl | * Release Version: 1.0.8.3 |
8 | 1 | simandl | * Date Started: 2004/08/20 |
9 | | | * |
10 | | | * BASH language file for GeSHi. |
11 | | | * |
12 | | | * CHANGES |
13 | | | * ------- |
14 | | | * 2008/06/21 (1.0.8) |
15 | | | * - Added loads of keywords and commands of GNU/Linux |
16 | | | * - Added support for parameters starting with a dash |
17 | | | * 2008/05/23 (1.0.7.22) |
18 | | | * - Added description of extra language features (SF#1970248) |
19 | | | * 2007/09/05 (1.0.7.21) |
20 | | | * - PARSER_CONTROL patch using SF #1788408 (BenBE) |
21 | | | * 2007/06/11 (1.0.7.20) |
22 | | | * - Added a lot of keywords (BenBE / Jan G) |
23 | | | * 2004/11/27 (1.0.2) |
24 | | | * - Added support for multiple object splitters |
25 | | | * 2004/10/27 (1.0.1) |
26 | | | * - Added support for URLs |
27 | | | * 2004/08/20 (1.0.0) |
28 | | | * - First Release |
29 | | | * |
30 | | | * TODO (updated 2004/11/27) |
31 | | | * ------------------------- |
32 | | | * * Get symbols working |
33 | | | * * Highlight builtin vars |
34 | | | * |
35 | | | ************************************************************************************* |
36 | | | * |
37 | | | * This file is part of GeSHi. |
38 | | | * |
39 | | | * GeSHi is free software; you can redistribute it and/or modify |
40 | | | * it under the terms of the GNU General Public License as published by |
41 | | | * the Free Software Foundation; either version 2 of the License, or |
42 | | | * (at your option) any later version. |
43 | | | * |
44 | | | * GeSHi is distributed in the hope that it will be useful, |
45 | | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
46 | | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
47 | | | * GNU General Public License for more details. |
48 | | | * |
49 | | | * You should have received a copy of the GNU General Public License |
50 | | | * along with GeSHi; if not, write to the Free Software |
51 | | | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
52 | | | * |
53 | | | ************************************************************************************/ |
54 | | | |
55 | | | $language_data = array ( |
56 | | | 'LANG_NAME' => 'Bash', |
57 | | | // Bash DOES have single line comments with # markers. But bash also has |
58 | | | // the $# variable, so comments need special handling (see sf.net |
59 | | | // 1564839) |
60 | | | 'COMMENT_SINGLE' => array('#'), |
61 | | | 'COMMENT_MULTI' => array(), |
62 | | | 'COMMENT_REGEXP' => array( |
63 | | | //Variables |
64 | | | 1 => "/\\$\\{[^\\n\\}]*?\\}/i", |
65 | | | //BASH-style Heredoc |
66 | 3 | simandl | 2 => '/<<-?\s*?(\'?)([a-zA-Z0-9]+)\1\\n.*\\n\\2(?![a-zA-Z0-9])/siU', |
67 | 1 | simandl | //Escaped String Starters |
68 | | | 3 => "/\\\\['\"]/siU" |
69 | | | ), |
70 | | | 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE, |
71 | | | 'QUOTEMARKS' => array('"'), |
72 | | | 'HARDQUOTE' => array("'", "'"), |
73 | | | 'HARDESCAPE' => array("\'"), |
74 | | | 'ESCAPE_CHAR' => '', |
75 | | | 'ESCAPE_REGEXP' => array( |
76 | | | //Simple Single Char Escapes |
77 | | | 1 => "#\\\\[nfrtv\\$\\\"\n]#i", |
78 | | | // $var |
79 | | | 2 => "#\\$[a-z_][a-z0-9_]*#i", |
80 | | | // ${...} |
81 | | | 3 => "/\\$\\{[^\\n\\}]*?\\}/i", |
82 | | | // $(...) |
83 | | | 4 => "/\\$\\([^\\n\\)]*?\\)/i", |
84 | | | // `...` |
85 | | | 5 => "/`[^`]*`/" |
86 | | | ), |
87 | | | 'KEYWORDS' => array( |
88 | | | 1 => array( |
89 | | | 'case', 'do', 'done', 'elif', 'else', 'esac', 'fi', 'for', 'function', |
90 | | | 'if', 'in', 'select', 'set', 'then', 'until', 'while', 'time' |
91 | | | ), |
92 | | | 2 => array( |
93 | | | 'aclocal', 'aconnect', 'aplay', 'apm', 'apmsleep', 'apropos', |
94 | | | 'apt-cache', 'apt-get', 'apt-key', 'aptitude', |
95 | | | 'ar', 'arch', 'arecord', 'as', 'as86', 'ash', 'autoconf', |
96 | | | 'autoheader', 'automake', 'awk', |
97 | | | |
98 | | | 'basename', 'bash', 'bc', 'bison', 'bunzip2', 'bzcat', |
99 | | | 'bzcmp', 'bzdiff', 'bzegrep', 'bzfgrep', 'bzgrep', |
100 | | | 'bzip2', 'bzip2recover', 'bzless', 'bzmore', |
101 | | | |
102 | | | 'c++', 'cal', 'cat', 'chattr', 'cc', 'cdda2wav', 'cdparanoia', |
103 | | | 'cdrdao', 'cd-read', 'cdrecord', 'chfn', 'chgrp', 'chmod', |
104 | | | 'chown', 'chroot', 'chsh', 'chvt', 'clear', 'cmp', 'comm', 'co', |
105 | | | 'col', 'cp', 'cpio', 'cpp', 'csh', 'cut', 'cvs', 'cvs-pserver', |
106 | | | |
107 | | | 'dash', 'date', 'dd', 'dc', 'dcop', 'deallocvt', 'df', 'dialog', |
108 | | | 'diff', 'diff3', 'dir', 'dircolors', 'directomatic', 'dirname', |
109 | | | 'dmesg', 'dnsdomainname', 'domainname', 'dpkg', 'dselect', 'du', |
110 | | | 'dumpkeys', |
111 | | | |
112 | | | 'ed', 'egrep', 'env', 'expr', |
113 | | | |
114 | | | 'false', 'fbset', 'ffmpeg', 'fgconsole','fgrep', 'file', 'find', |
115 | | | 'flex', 'flex++', 'fmt', 'free', 'ftp', 'funzip', 'fuser', |
116 | | | |
117 | | | 'g++', 'gawk', 'gc','gcc', 'gdb', 'getent', 'getkeycodes', |
118 | | | 'getopt', 'gettext', 'gettextize', 'gimp', 'gimp-remote', |
119 | | | 'gimptool', 'gmake', 'gocr', 'grep', 'groups', 'gs', 'gunzip', |
120 | | | 'gzexe', 'gzip', |
121 | | | |
122 | | | 'head', 'hexdump', 'hostname', |
123 | | | |
124 | | | 'id', 'ifconfig', 'igawk', 'install', |
125 | | | |
126 | | | 'join', |
127 | | | |
128 | | | 'kbd_mode','kbdrate', 'kdialog', 'kfile', 'kill', 'killall', |
129 | | | |
130 | | | 'lame', 'last', 'lastb', 'ld', 'ld86', 'ldd', 'less', 'lex', 'link', |
131 | | | 'ln', 'loadkeys', 'loadunimap', 'locate', 'lockfile', 'login', |
132 | | | 'logname', 'lp', 'lpr', 'ls', 'lsattr', 'lsmod', 'lsmod.old', |
133 | | | 'lspci', 'ltrace', 'lynx', |
134 | | | |
135 | | | 'm4', 'make', 'man', 'mapscrn', 'mesg', 'mkdir', 'mkfifo', |
136 | | | 'mknod', 'mktemp', 'more', 'mount', 'mplayer', 'msgfmt', 'mv', |
137 | | | |
138 | | | 'namei', 'nano', 'nasm', 'nawk', 'netstat', 'nice', |
139 | | | 'nisdomainname', 'nl', 'nm', 'nm86', 'nmap', 'nohup', 'nop', |
140 | | | |
141 | | | 'od', 'openvt', |
142 | | | |
143 | | | 'passwd', 'patch', 'pcregrep', 'pcretest', 'perl', 'perror', |
144 | | | 'pgawk', 'pidof', 'ping', 'pr', 'procmail', 'prune', 'ps', 'pstree', |
145 | | | 'ps2ascii', 'ps2epsi', 'ps2frag', 'ps2pdf', 'ps2ps', 'psbook', |
146 | | | 'psmerge', 'psnup', 'psresize', 'psselect', 'pstops', |
147 | | | |
148 | | | 'rbash', 'rcs', 'rcs2log', 'read', 'readlink', 'red', 'resizecons', |
149 | | | 'rev', 'rm', 'rmdir', 'rsh', 'run-parts', |
150 | | | |
151 | | | 'sash', 'scp', 'screen', 'sed', 'seq', 'sendmail', 'setfont', |
152 | | | 'setkeycodes', 'setleds', 'setmetamode', 'setserial', 'setterm', |
153 | | | 'sh', 'showkey', 'shred', 'size', 'size86', 'skill', 'sleep', |
154 | | | 'slogin', 'snice', 'sort', 'sox', 'split', 'ssed', 'ssh', 'ssh-add', |
155 | | | 'ssh-agent', 'ssh-keygen', 'ssh-keyscan', 'stat', 'strace', |
156 | | | 'strings', 'strip', 'stty', 'su', 'sudo', 'suidperl', 'sum', 'svn', |
157 | | | 'svnadmin', 'svndumpfilter', 'svnlook', 'svnmerge', 'svnmucc', |
158 | | | 'svnserve', 'svnshell', 'svnsync', 'svnversion', 'svnwrap', 'sync', |
159 | | | |
160 | | | 'tac', 'tail', 'tar', 'tee', 'tempfile', 'touch', 'tr', 'tree', |
161 | | | 'true', |
162 | | | |
163 | | | 'umount', 'uname', 'unicode_start', 'unicode_stop', 'uniq', |
164 | | | 'unlink', 'unzip', 'updatedb', 'updmap', 'uptime', 'users', |
165 | | | 'utmpdump', 'uuidgen', |
166 | | | |
167 | | | 'valgrind', 'vdir', 'vi', 'vim', 'vmstat', |
168 | | | |
169 | | | 'w', 'wall', 'wc', 'wget', 'whatis', 'whereis', 'which', 'whiptail', |
170 | | | 'who', 'whoami', 'write', |
171 | | | |
172 | | | 'xargs', 'xhost', 'xmodmap', 'xset', |
173 | | | |
174 | | | 'yacc', 'yes', 'ypdomainname', |
175 | | | |
176 | | | 'zcat', 'zcmp', 'zdiff', 'zdump', 'zegrep', 'zfgrep', 'zforce', |
177 | | | 'zgrep', 'zip', 'zipgrep', 'zipinfo', 'zless', 'zmore', 'znew', |
178 | | | 'zsh', 'zsoelim' |
179 | | | ), |
180 | | | 3 => array( |
181 | | | 'alias', 'bg', 'bind', 'break', 'builtin', 'cd', 'command', |
182 | | | 'compgen', 'complete', 'continue', 'declare', 'dirs', 'disown', |
183 | | | 'echo', 'enable', 'eval', 'exec', 'exit', 'export', 'fc', |
184 | | | 'fg', 'getopts', 'hash', 'help', 'history', 'jobs', 'let', |
185 | | | 'local', 'logout', 'popd', 'printf', 'pushd', 'pwd', 'readonly', |
186 | | | 'return', 'shift', 'shopt', 'source', 'suspend', 'test', 'times', |
187 | | | 'trap', 'type', 'typeset', 'ulimit', 'umask', 'unalias', 'unset', |
188 | | | 'wait' |
189 | | | ) |
190 | | | ), |
191 | | | 'SYMBOLS' => array( |
192 | | | '(', ')', '[', ']', '!', '@', '%', '&', '*', '|', '/', '<', '>', ';;', '`' |
193 | | | ), |
194 | | | 'CASE_SENSITIVE' => array( |
195 | | | GESHI_COMMENTS => false, |
196 | | | 1 => true, |
197 | | | 2 => true, |
198 | | | 3 => true |
199 | | | ), |
200 | | | 'STYLES' => array( |
201 | | | 'KEYWORDS' => array( |
202 | | | 1 => 'color: #000000; font-weight: bold;', |
203 | | | 2 => 'color: #c20cb9; font-weight: bold;', |
204 | | | 3 => 'color: #7a0874; font-weight: bold;' |
205 | | | ), |
206 | | | 'COMMENTS' => array( |
207 | | | |
208 | | | 1 => 'color: #800000;', |
209 | | | 2 => 'color: #cc0000; font-style: italic;', |
210 | | | 3 => 'color: #000000; font-weight: bold;' |
211 | | | ), |
212 | | | 'ESCAPE_CHAR' => array( |
213 | | | 1 => 'color: #000099; font-weight: bold;', |
214 | | | 2 => 'color: #007800;', |
215 | | | 3 => 'color: #007800;', |
216 | | | 4 => 'color: #007800;', |
217 | | | 5 => 'color: #780078;', |
218 | | | 'HARD' => 'color: #000099; font-weight: bold;' |
219 | | | ), |
220 | | | 'BRACKETS' => array( |
221 | | | |
222 | | | ), |
223 | | | 'STRINGS' => array( |
224 | | | |
225 | | | 'HARD' => 'color: #ff0000;' |
226 | | | ), |
227 | | | 'NUMBERS' => array( |
228 | | | |
229 | | | ), |
230 | | | 'METHODS' => array( |
231 | | | ), |
232 | | | 'SYMBOLS' => array( |
233 | | | |
234 | | | ), |
235 | | | 'REGEXPS' => array( |
236 | | | |
237 | | | 1 => 'color: #007800;', |
238 | | | 2 => 'color: #007800;', |
239 | | | 4 => 'color: #007800;', |
240 | | | 5 => 'color: #660033;' |
241 | | | ), |
242 | | | 'SCRIPT' => array( |
243 | | | ) |
244 | | | ), |
245 | | | 'URLS' => array( |
246 | | | 1 => '', |
247 | | | 2 => '', |
248 | | | 3 => '' |
249 | | | ), |
250 | | | 'OOLANG' => false, |
251 | | | 'OBJECT_SPLITTERS' => array( |
252 | | | ), |
253 | | | 'REGEXPS' => array( |
254 | | | //Variables (will be handled by comment_regexps) |
255 | | | |
256 | | | //Variables without braces |
257 | | | 1 => "\\$[a-zA-Z_][a-zA-Z0-9_]*", |
258 | | | //Variable assignment |
259 | | | 2 => "(?<![\.a-zA-Z_\-])([a-zA-Z_][a-zA-Z0-9_]*?)(?==)", |
260 | | | //Shorthand shell variables |
261 | | | 4 => "\\$[*#\$\\-\\?!]", |
262 | | | //Parameters of commands |
263 | | | 5 => "(?<=\s)--?[0-9a-zA-Z\-]+(?=[\s=]|$)" |
264 | | | ), |
265 | | | 'STRICT_MODE_APPLIES' => GESHI_NEVER, |
266 | | | 'SCRIPT_DELIMITERS' => array( |
267 | | | ), |
268 | | | 'HIGHLIGHT_STRICT_BLOCK' => array( |
269 | | | ), |
270 | | | 'TAB_WIDTH' => 4, |
271 | | | 'PARSER_CONTROL' => array( |
272 | | | 'COMMENTS' => array( |
273 | | | 'DISALLOWED_BEFORE' => '$' |
274 | | | ), |
275 | | | 'KEYWORDS' => array( |
276 | | | 'DISALLOWED_BEFORE' => "(?<![\.\-a-zA-Z0-9_\$\#])", |
277 | 3 | simandl | 'DISALLOWED_AFTER' => "(?![\.\-a-zA-Z0-9_%\\/])" |
278 | 1 | simandl | ) |
279 | | | ) |
280 | | | ); |
281 | | | |
282 | 3 | simandl | ?> |