PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/inc/geshi/bash.php

http://github.com/splitbrain/dokuwiki
PHP | 327 lines | 262 code | 2 blank | 63 comment | 0 complexity | 54d76253de12e6de5bb7797be7e82008 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1, GPL-2.0
  1. <?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. * Release Version: 1.0.8.8
  8. * 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. $language_data = array (
  55. 'LANG_NAME' => 'Bash',
  56. // Bash DOES have single line comments with # markers. But bash also has
  57. // the $# variable, so comments need special handling (see sf.net
  58. // 1564839)
  59. 'COMMENT_SINGLE' => array('#'),
  60. 'COMMENT_MULTI' => array(),
  61. 'COMMENT_REGEXP' => array(
  62. //Variables
  63. 1 => "/\\$\\{[^\\n\\}]*?\\}/i",
  64. //BASH-style Heredoc
  65. 2 => '/<<-?\s*?(\'?)([a-zA-Z0-9]+)\1\\n.*\\n\\2(?![a-zA-Z0-9])/siU',
  66. //Escaped String Starters
  67. 3 => "/\\\\['\"]/siU"
  68. ),
  69. 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
  70. 'QUOTEMARKS' => array('"'),
  71. 'HARDQUOTE' => array("'", "'"),
  72. 'HARDESCAPE' => array("\'"),
  73. 'ESCAPE_CHAR' => '',
  74. 'ESCAPE_REGEXP' => array(
  75. //Simple Single Char Escapes
  76. 1 => "#\\\\[nfrtv\\$\\\"\n]#i",
  77. // $var
  78. 2 => "#\\$[a-z_][a-z0-9_]*#i",
  79. // ${...}
  80. 3 => "/\\$\\{[^\\n\\}]*?\\}/i",
  81. // $(...)
  82. 4 => "/\\$\\([^\\n\\)]*?\\)/i",
  83. // `...`
  84. 5 => "/`[^`]*`/"
  85. ),
  86. 'KEYWORDS' => array(
  87. 1 => array(
  88. 'case', 'do', 'done', 'elif', 'else', 'esac', 'fi', 'for', 'function',
  89. 'if', 'in', 'select', 'set', 'then', 'until', 'while', 'time'
  90. ),
  91. 2 => array(
  92. 'aclocal', 'aconnect', 'aplay', 'apm', 'apmsleep', 'apropos',
  93. 'apt-cache', 'apt-file', 'apt-get', 'apt-key', 'apt-src', 'aptitude',
  94. 'ar', 'arch', 'arecord', 'as', 'as86', 'ash', 'autoconf',
  95. 'autoheader', 'automake', 'awk',
  96. 'basename', 'bash', 'bc', 'bison', 'bunzip2', 'bzcat',
  97. 'bzcmp', 'bzdiff', 'bzegrep', 'bzfgrep', 'bzgrep',
  98. 'bzip2', 'bzip2recover', 'bzless', 'bzmore',
  99. 'c++', 'cal', 'cat', 'chattr', 'cc', 'cdda2wav', 'cdparanoia',
  100. 'cdrdao', 'cd-read', 'cdrecord', 'chfn', 'chgrp', 'chmod',
  101. 'chown', 'chroot', 'chsh', 'chvt', 'clear', 'cmp', 'comm', 'co',
  102. 'col', 'cp', 'cpio', 'cpp', 'csh', 'cut', 'cvs', 'cvs-pserver',
  103. 'dash', 'date', 'dc', 'dch', 'dcop', 'dd', 'ddate', 'ddd',
  104. 'deallocvt', 'debconf', 'defoma', 'depmod', 'df', 'dh',
  105. 'dialog', 'diff', 'diff3', 'dig', 'dir', 'dircolors', 'directomatic',
  106. 'dirname', 'dmesg', 'dnsdomainname', 'domainname', 'dpkg',
  107. 'dselect', 'du', 'dumpkeys',
  108. 'ed', 'egrep', 'env', 'expr',
  109. 'false', 'fbset', 'ffmpeg', 'fgconsole','fgrep', 'file', 'find',
  110. 'flex', 'flex++', 'fmt', 'free', 'ftp', 'funzip', 'fuser',
  111. 'g++', 'gawk', 'gc','gcc', 'gdb', 'getent', 'getkeycodes',
  112. 'getopt', 'gettext', 'gettextize', 'gimp', 'gimp-remote',
  113. 'gimptool', 'gmake', 'gocr', 'grep', 'groups', 'gs', 'gunzip',
  114. 'gzexe', 'gzip',
  115. 'git', 'gitaction', 'git-add', 'git-add--interactive', 'git-am',
  116. 'git-annotate', 'git-apply', 'git-archive', 'git-bisect',
  117. 'git-bisect--helper', 'git-blame', 'git-branch', 'git-bundle',
  118. 'git-cat-file', 'git-check-attr', 'git-checkout',
  119. 'git-checkout-index', 'git-check-ref-format', 'git-cherry',
  120. 'git-cherry-pick', 'git-clean', 'git-clone', 'git-commit',
  121. 'git-commit-tree', 'git-config', 'git-count-objects', 'git-daemon',
  122. 'git-describe', 'git-diff', 'git-diff-files', 'git-diff-index',
  123. 'git-difftool', 'git-difftool--helper', 'git-diff-tree',
  124. 'gitdpkgname', 'git-fast-export', 'git-fast-import', 'git-fetch',
  125. 'git-fetch-pack', 'git-fetch--tool', 'git-filter-branch', 'gitfm',
  126. 'git-fmt-merge-msg', 'git-for-each-ref', 'git-format-patch',
  127. 'git-fsck', 'git-fsck-objects', 'git-gc', 'git-get-tar-commit-id',
  128. 'git-grep', 'git-hash-object', 'git-help', 'git-http-fetch',
  129. 'git-http-push', 'git-imap-send', 'git-index-pack', 'git-init',
  130. 'git-init-db', 'git-instaweb', 'gitkeys', 'git-log',
  131. 'git-lost-found', 'git-ls-files', 'git-ls-remote', 'git-ls-tree',
  132. 'git-mailinfo', 'git-mailsplit', 'git-merge', 'git-merge-base',
  133. 'git-merge-file', 'git-merge-index', 'git-merge-octopus',
  134. 'git-merge-one-file', 'git-merge-ours', 'git-merge-recursive',
  135. 'git-merge-resolve', 'git-merge-subtree', 'git-mergetool',
  136. 'git-mergetool--lib', 'git-merge-tree', 'gitmkdirs', 'git-mktag',
  137. 'git-mktree', 'gitmount', 'git-mv', 'git-name-rev',
  138. 'git-pack-objects', 'git-pack-redundant', 'git-pack-refs',
  139. 'git-parse-remote', 'git-patch-id', 'git-peek-remote', 'git-prune',
  140. 'git-prune-packed', 'gitps', 'git-pull', 'git-push',
  141. 'git-quiltimport', 'git-read-tree', 'git-rebase',
  142. 'git-rebase--interactive', 'git-receive-pack', 'git-reflog',
  143. 'gitregrep', 'git-relink', 'git-remote', 'git-repack',
  144. 'git-repo-config', 'git-request-pull', 'git-rerere', 'git-reset',
  145. 'git-revert', 'git-rev-list', 'git-rev-parse', 'gitrfgrep',
  146. 'gitrgrep', 'git-rm', 'git-send-pack', 'git-shell', 'git-shortlog',
  147. 'git-show', 'git-show-branch', 'git-show-index', 'git-show-ref',
  148. 'git-sh-setup', 'git-stage', 'git-stash', 'git-status',
  149. 'git-stripspace', 'git-submodule', 'git-svn', 'git-symbolic-ref',
  150. 'git-tag', 'git-tar-tree', 'gitunpack', 'git-unpack-file',
  151. 'git-unpack-objects', 'git-update-index', 'git-update-ref',
  152. 'git-update-server-info', 'git-upload-archive', 'git-upload-pack',
  153. 'git-var', 'git-verify-pack', 'git-verify-tag', 'gitview',
  154. 'git-web--browse', 'git-whatchanged', 'gitwhich', 'gitwipe',
  155. 'git-write-tree', 'gitxgrep',
  156. 'head', 'hexdump', 'hostname',
  157. 'id', 'ifconfig', 'ifdown', 'ifup', 'igawk', 'install',
  158. 'join',
  159. 'kbd_mode','kbdrate', 'kdialog', 'kfile', 'kill', 'killall',
  160. 'lame', 'last', 'lastb', 'ld', 'ld86', 'ldd', 'less', 'lex', 'link',
  161. 'ln', 'loadkeys', 'loadunimap', 'locate', 'lockfile', 'login',
  162. 'logname', 'lp', 'lpr', 'ls', 'lsattr', 'lsmod', 'lsmod.old',
  163. 'lspci', 'ltrace', 'lynx',
  164. 'm4', 'make', 'man', 'mapscrn', 'mesg', 'mkdir', 'mkfifo',
  165. 'mknod', 'mktemp', 'more', 'mount', 'mplayer', 'msgfmt', 'mv',
  166. 'namei', 'nano', 'nasm', 'nawk', 'netstat', 'nice',
  167. 'nisdomainname', 'nl', 'nm', 'nm86', 'nmap', 'nohup', 'nop',
  168. 'od', 'openvt',
  169. 'passwd', 'patch', 'pcregrep', 'pcretest', 'perl', 'perror',
  170. 'pgawk', 'pidof', 'ping', 'pr', 'procmail', 'prune', 'ps', 'pstree',
  171. 'ps2ascii', 'ps2epsi', 'ps2frag', 'ps2pdf', 'ps2ps', 'psbook',
  172. 'psmerge', 'psnup', 'psresize', 'psselect', 'pstops',
  173. 'rbash', 'rcs', 'rcs2log', 'read', 'readlink', 'red', 'resizecons',
  174. 'rev', 'rm', 'rmdir', 'rsh', 'run-parts',
  175. 'sash', 'scp', 'screen', 'sed', 'seq', 'sendmail', 'setfont',
  176. 'setkeycodes', 'setleds', 'setmetamode', 'setserial', 'setterm',
  177. 'sh', 'showkey', 'shred', 'size', 'size86', 'skill', 'sleep',
  178. 'slogin', 'snice', 'sort', 'sox', 'split', 'ssed', 'ssh', 'ssh-add',
  179. 'ssh-agent', 'ssh-keygen', 'ssh-keyscan', 'stat', 'strace',
  180. 'strings', 'strip', 'stty', 'su', 'sudo', 'suidperl', 'sum', 'svn',
  181. 'svnadmin', 'svndumpfilter', 'svnlook', 'svnmerge', 'svnmucc',
  182. 'svnserve', 'svnshell', 'svnsync', 'svnversion', 'svnwrap', 'sync',
  183. 'tac', 'tail', 'tar', 'tee', 'tempfile', 'touch', 'tr', 'tree',
  184. 'true',
  185. 'umount', 'uname', 'unicode_start', 'unicode_stop', 'uniq',
  186. 'unlink', 'unzip', 'updatedb', 'updmap', 'uptime', 'users',
  187. 'utmpdump', 'uuidgen',
  188. 'valgrind', 'vdir', 'vi', 'vim', 'vmstat',
  189. 'w', 'wall', 'watch', 'wc', 'wget', 'whatis', 'whereis',
  190. 'which', 'whiptail', 'who', 'whoami', 'whois', 'wine', 'wineboot',
  191. 'winebuild', 'winecfg', 'wineconsole', 'winedbg', 'winedump',
  192. 'winefile', 'wodim', 'write',
  193. 'xargs', 'xhost', 'xmodmap', 'xset',
  194. 'yacc', 'yes', 'ypdomainname',
  195. 'zcat', 'zcmp', 'zdiff', 'zdump', 'zegrep', 'zfgrep', 'zforce',
  196. 'zgrep', 'zip', 'zipgrep', 'zipinfo', 'zless', 'zmore', 'znew',
  197. 'zsh', 'zsoelim'
  198. ),
  199. 3 => array(
  200. 'alias', 'bg', 'bind', 'break', 'builtin', 'cd', 'command',
  201. 'compgen', 'complete', 'continue', 'declare', 'dirs', 'disown',
  202. 'echo', 'enable', 'eval', 'exec', 'exit', 'export', 'fc',
  203. 'fg', 'getopts', 'hash', 'help', 'history', 'jobs', 'let',
  204. 'local', 'logout', 'popd', 'printf', 'pushd', 'pwd', 'readonly',
  205. 'return', 'shift', 'shopt', 'source', 'suspend', 'test', 'times',
  206. 'trap', 'type', 'typeset', 'ulimit', 'umask', 'unalias', 'unset',
  207. 'wait'
  208. )
  209. ),
  210. 'SYMBOLS' => array(
  211. '(', ')', '[', ']', '!', '@', '%', '&', '*', '|', '/', '<', '>', ';;', '`'
  212. ),
  213. 'CASE_SENSITIVE' => array(
  214. GESHI_COMMENTS => false,
  215. 1 => true,
  216. 2 => true,
  217. 3 => true
  218. ),
  219. 'STYLES' => array(
  220. 'KEYWORDS' => array(
  221. 1 => 'color: #000000; font-weight: bold;',
  222. 2 => 'color: #c20cb9; font-weight: bold;',
  223. 3 => 'color: #7a0874; font-weight: bold;'
  224. ),
  225. 'COMMENTS' => array(
  226. 0 => 'color: #666666; font-style: italic;',
  227. 1 => 'color: #800000;',
  228. 2 => 'color: #cc0000; font-style: italic;',
  229. 3 => 'color: #000000; font-weight: bold;'
  230. ),
  231. 'ESCAPE_CHAR' => array(
  232. 1 => 'color: #000099; font-weight: bold;',
  233. 2 => 'color: #007800;',
  234. 3 => 'color: #007800;',
  235. 4 => 'color: #007800;',
  236. 5 => 'color: #780078;',
  237. 'HARD' => 'color: #000099; font-weight: bold;'
  238. ),
  239. 'BRACKETS' => array(
  240. 0 => 'color: #7a0874; font-weight: bold;'
  241. ),
  242. 'STRINGS' => array(
  243. 0 => 'color: #ff0000;',
  244. 'HARD' => 'color: #ff0000;'
  245. ),
  246. 'NUMBERS' => array(
  247. 0 => 'color: #000000;'
  248. ),
  249. 'METHODS' => array(
  250. ),
  251. 'SYMBOLS' => array(
  252. 0 => 'color: #000000; font-weight: bold;'
  253. ),
  254. 'REGEXPS' => array(
  255. 0 => 'color: #007800;',
  256. 1 => 'color: #007800;',
  257. 2 => 'color: #007800;',
  258. 4 => 'color: #007800;',
  259. 5 => 'color: #660033;'
  260. ),
  261. 'SCRIPT' => array(
  262. )
  263. ),
  264. 'URLS' => array(
  265. 1 => '',
  266. 2 => '',
  267. 3 => ''
  268. ),
  269. 'OOLANG' => false,
  270. 'OBJECT_SPLITTERS' => array(
  271. ),
  272. 'REGEXPS' => array(
  273. //Variables (will be handled by comment_regexps)
  274. 0 => "\\$\\{[a-zA-Z_][a-zA-Z0-9_]*?\\}",
  275. //Variables without braces
  276. 1 => "\\$[a-zA-Z_][a-zA-Z0-9_]*",
  277. //Variable assignment
  278. 2 => "(?<![\.a-zA-Z_\-])([a-zA-Z_][a-zA-Z0-9_]*?)(?==)",
  279. //Shorthand shell variables
  280. 4 => "\\$[*#\$\\-\\?!\d]",
  281. //Parameters of commands
  282. 5 => "(?<=\s)--?[0-9a-zA-Z\-]+(?=[\s=]|<(?:SEMI|PIPE)>|$)"
  283. ),
  284. 'STRICT_MODE_APPLIES' => GESHI_NEVER,
  285. 'SCRIPT_DELIMITERS' => array(
  286. ),
  287. 'HIGHLIGHT_STRICT_BLOCK' => array(
  288. ),
  289. 'TAB_WIDTH' => 4,
  290. 'PARSER_CONTROL' => array(
  291. 'COMMENTS' => array(
  292. 'DISALLOWED_BEFORE' => '$'
  293. ),
  294. 'KEYWORDS' => array(
  295. 'DISALLOWED_BEFORE' => "(?<![\.\-a-zA-Z0-9_\$\#])",
  296. 'DISALLOWED_AFTER' => "(?![\.\-a-zA-Z0-9_%=\\/])"
  297. )
  298. )
  299. );
  300. ?>