plugins/geshi/geshi/bash.php
changeset 2 9e3258dfae15
parent 0 441963e5b07a
child 3 f3e2bbbd2155
equal deleted inserted replaced
1:c715631f809a 2:9e3258dfae15
     2 /*************************************************************************************
     2 /*************************************************************************************
     3  * bash.php
     3  * bash.php
     4  * --------
     4  * --------
     5  * Author: Andreas Gohr (andi@splitbrain.org)
     5  * Author: Andreas Gohr (andi@splitbrain.org)
     6  * Copyright: (c) 2004 Andreas Gohr, Nigel McNie (http://qbnz.com/highlighter)
     6  * Copyright: (c) 2004 Andreas Gohr, Nigel McNie (http://qbnz.com/highlighter)
     7  * Release Version: 1.0.7.20
     7  * Release Version: 1.0.8.2
     8  * Date Started: 2004/08/20
     8  * Date Started: 2004/08/20
     9  *
     9  *
    10  * BASH language file for GeSHi.
    10  * BASH language file for GeSHi.
    11  *
    11  *
    12  * CHANGES
    12  * CHANGES
    13  * -------
    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)
    14  * 2007/06/11 (1.0.7.20)
    21  * 2007/06/11 (1.0.7.20)
    15  *  -  Added a lot of keywords (BenBE / Jan G)
    22  *  -  Added a lot of keywords (BenBE / Jan G)
    16  * 2004/11/27 (1.0.2)
    23  * 2004/11/27 (1.0.2)
    17  *  -  Added support for multiple object splitters
    24  *  -  Added support for multiple object splitters
    18  * 2004/10/27 (1.0.1)
    25  * 2004/10/27 (1.0.1)
    48 $language_data = array (
    55 $language_data = array (
    49     'LANG_NAME' => 'Bash',
    56     'LANG_NAME' => 'Bash',
    50     // Bash DOES have single line comments with # markers. But bash also has
    57     // Bash DOES have single line comments with # markers. But bash also has
    51     // the  $# variable, so comments need special handling (see sf.net
    58     // the  $# variable, so comments need special handling (see sf.net
    52     // 1564839)
    59     // 1564839)
    53 	'COMMENT_SINGLE' => array(),
    60     'COMMENT_SINGLE' => array('#'),
    54 	'COMMENT_MULTI' => array(),
    61     'COMMENT_MULTI' => array(),
    55 	'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
    62     'COMMENT_REGEXP' => array(
    56 	'QUOTEMARKS' => array("'", '"'),
    63         //Variables
    57 	'ESCAPE_CHAR' => '\\',
    64         1 => "/\\$\\{[^\\n\\}]*?\\}/i",
    58 	'KEYWORDS' => array(
    65         //BASH-style Heredoc
    59 		1 => array(
    66         2 => '/<<-?\s*?(\'?)([a-zA-Z0-9]+)\1\\n.*\\n\\2(?![a-zA-Z0-9])/siU',
    60 			'case', 'do', 'done', 'elif', 'else', 'esac', 'fi', 'for', 'function',
    67         //Escaped String Starters
    61 			'if', 'in', 'select', 'set', 'then', 'until', 'while', 'time'
    68         3 => "/\\\\['\"]/siU"
    62 			),
    69         ),
    63 		2 => array(
    70     'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
    64 			'aclocal', 'aconnect', 'aplay', 'apm', 'apmsleep', 'apropos',
    71     'QUOTEMARKS' => array('"'),
    65 			'ar', 'arch', 'arecord', 'as', 'as86', 'autoconf', 'autoheader',
    72     'HARDQUOTE' => array("'", "'"),
    66 			'automake', 'awk',
    73     'HARDESCAPE' => array("\'"),
    67 			'basename', 'bc', 'bison', 'bunzip2', 'bzip2', 'bzcat',
    74     'ESCAPE_CHAR' => '',
    68 			'bzcmp', 'bzdiff', 'bzegrep', 'bzegrep', 'bzfgrep', 'bzgrep',
    75     'ESCAPE_REGEXP' => array(
    69 			'bzip2', 'bzip2recover', 'bzless', 'bzmore',
    76         //Simple Single Char Escapes
    70 			'c++', 'cal', 'cat', 'chattr', 'cc', 'cdda2wav', 'cdparanoia',
    77         1 => "#\\\\[nfrtv\\$\\\"\n]#i",
    71 			'cdrdao', 'cd-read', 'cdrecord', 'chfn', 'chgrp', 'chmod',
    78         // $var
    72 			'chown', 'chroot', 'chsh', 'chvt', 'clear', 'cmp', 'comm', 'co',
    79         2 => "#\\$[a-z_][a-z0-9_]*#i",
    73 			'col', 'cp', 'cpio', 'cpp', 'cut',
    80         // ${...}
    74 			'date', 'dd', 'dc', 'dcop', 'deallocvt', 'df', 'diff', 'diff3', 'dir',
    81         3 => "/\\$\\{[^\\n\\}]*?\\}/i",
    75 			'dircolors', 'directomatic', 'dirname', 'dmesg',
    82         // $(...)
    76 			'dnsdomainname', 'domainname', 'du', 'dumpkeys',
    83         4 => "/\\$\\([^\\n\\)]*?\\)/i",
    77 			'ed', 'egrep', 'env', 'expr',
    84         // `...`
    78 			'false', 'fbset', 'fgconsole','fgrep', 'find', 'file', 'flex', 'flex++',
    85         5 => "/`[^`]*`/"
    79 			'fmt', 'free', 'ftp', 'funzip', 'fuser',
    86         ),
    80 			'g++', 'gawk', 'gc','gcc', 'gdb', 'getent', 'getkeycodes',
    87     'KEYWORDS' => array(
    81 			'getopt', 'gettext', 'gettextize', 'gimp', 'gimp-remote',
    88         1 => array(
    82 			'gimptool', 'gmake', 'gocr', 'grep', 'groups', 'gs', 'gunzip',
    89             'case', 'do', 'done', 'elif', 'else', 'esac', 'fi', 'for', 'function',
    83 			'gzexe', 'gzip',
    90             'if', 'in', 'select', 'set', 'then', 'until', 'while', 'time'
    84 			'head', 'hexdump', 'hostname',
    91             ),
    85 			'id', 'igawk', 'install',
    92         2 => array(
    86 			'join',
    93             'aclocal', 'aconnect', 'aplay', 'apm', 'apmsleep', 'apropos',
    87 			'kbd_mode','kbdrate', 'kdialog', 'kfile', 'kill', 'killall',
    94             'apt-cache', 'apt-get', 'apt-key', 'aptitude',
    88 			'last', 'lastb', 'ld', 'ld86', 'ldd', 'less', 'lex', 'link', 'ln', 'loadkeys',
    95             'ar', 'arch', 'arecord', 'as', 'as86', 'ash', 'autoconf',
    89 			'loadunimap', 'locate', 'lockfile', 'login', 'logname',
    96             'autoheader', 'automake', 'awk',
    90 			'lp', 'lpr', 'ls', 'lsattr', 'lsmod', 'lsmod.old', 'lynx',
    97 
    91 			'm4', 'make', 'man', 'mapscrn', 'mesg', 'mkdir', 'mkfifo', 
    98             'basename', 'bash', 'bc', 'bison', 'bunzip2', 'bzcat',
    92 			'mknod', 'mktemp', 'more', 'mount', 'msgfmt', 'mv',
    99             'bzcmp', 'bzdiff', 'bzegrep', 'bzfgrep', 'bzgrep',
    93 			'namei', 'nano', 'nasm', 'nawk', 'netstat', 'nice',
   100             'bzip2', 'bzip2recover', 'bzless', 'bzmore',
    94 			'nisdomainname', 'nl', 'nm', 'nm86', 'nmap', 'nohup', 'nop',
   101 
    95 			'od', 'openvt',
   102             'c++', 'cal', 'cat', 'chattr', 'cc', 'cdda2wav', 'cdparanoia',
    96 			'passwd', 'patch', 'pcregrep', 'pcretest', 'perl', 'perror',
   103             'cdrdao', 'cd-read', 'cdrecord', 'chfn', 'chgrp', 'chmod',
    97 			'pgawk', 'pidof', 'ping', 'pr', 'procmail', 'prune', 'ps', 'pstree',
   104             'chown', 'chroot', 'chsh', 'chvt', 'clear', 'cmp', 'comm', 'co',
    98 			'ps2ascii', 'ps2epsi', 'ps2frag', 'ps2pdf', 'ps2ps', 'psbook',
   105             'col', 'cp', 'cpio', 'cpp', 'csh', 'cut', 'cvs', 'cvs-pserver',
    99 			'psmerge', 'psnup', 'psresize', 'psselect', 'pstops',
   106 
   100 			'rbash', 'rcs', 'read', 'readlink', 'red', 'resizecons', 'rev', 'rm',
   107             'dash', 'date', 'dd', 'dc', 'dcop', 'deallocvt', 'df', 'dialog',
   101 			'rmdir', 'run-parts',
   108             'diff', 'diff3', 'dir', 'dircolors', 'directomatic', 'dirname',
   102 			'sash', 'sed', 'setfont', 'setkeycodes', 'setleds',
   109             'dmesg', 'dnsdomainname', 'domainname', 'dpkg', 'dselect', 'du',
   103 			'setmetamode', 'setserial', 'scp', 'seq', 'setterm', 'sh',
   110             'dumpkeys',
   104 			'showkey', 'shred', 'size', 'size86', 'skill', 'sleep', 'slogin',
   111 
   105 			'snice', 'sort', 'sox', 'split', 'ssed', 'ssh', 'ssh-add',
   112             'ed', 'egrep', 'env', 'expr',
   106 			'ssh-agent', 'ssh-keygen', 'ssh-keyscan', 'stat', 'strings',
   113 
   107 			'strip', 'stty', 'su', 'sudo', 'suidperl', 'sum', 'sync',
   114             'false', 'fbset', 'ffmpeg', 'fgconsole','fgrep', 'file', 'find',
   108 			'tac', 'tail', 'tar', 'tee', 'tempfile', 'touch', 'tr', 'true',
   115             'flex', 'flex++', 'fmt', 'free', 'ftp', 'funzip', 'fuser',
   109 			'umount', 'uname', 'unicode_start', 'unicode_stop', 'uniq',
   116 
   110 			'unlink', 'unzip', 'updatedb', 'updmap', 'uptime', 'users',
   117             'g++', 'gawk', 'gc','gcc', 'gdb', 'getent', 'getkeycodes',
   111 			'utmpdump', 'uuidgen',
   118             'getopt', 'gettext', 'gettextize', 'gimp', 'gimp-remote',
   112 			'vdir', 'vmstat',
   119             'gimptool', 'gmake', 'gocr', 'grep', 'groups', 'gs', 'gunzip',
   113 			'w', 'wall', 'wc', 'wget', 'whatis', 'whereis', 'which', 'who',
   120             'gzexe', 'gzip',
   114 			'whoami', 'write',
   121 
   115 			'xargs', 'xhost', 'xmodmap', 'xset',
   122             'head', 'hexdump', 'hostname',
   116 			'yacc', 'yes', 'ypdomainname',
   123 
   117 			'zcat', 'zcmp', 'zdiff', 'zegrep', 'zfgrep', 'zforce', 'zgrep',
   124             'id', 'ifconfig', 'igawk', 'install',
   118 			'zip', 'zless', 'zmore', 'znew', 'zsh', ' zsoelim'
   125 
   119 			),
   126             'join',
   120 		3 => array(
   127 
   121 			'alias', 'bg', 'bind', 'break', 'builtin', 'cd', 'command',
   128             'kbd_mode','kbdrate', 'kdialog', 'kfile', 'kill', 'killall',
   122 			'compgen', 'complete', 'continue', 'declare', 'dirs', 'disown',
   129 
   123 			'echo', 'enable', 'eval', 'exec', 'exit', 'export', 'fc',
   130             'lame', 'last', 'lastb', 'ld', 'ld86', 'ldd', 'less', 'lex', 'link',
   124 			'fg', 'getopts', 'hash', 'help', 'history', 'jobs', 'kill', 'let',
   131             'ln', 'loadkeys', 'loadunimap', 'locate', 'lockfile', 'login',
   125 			'local', 'logout', 'popd', 'printf', 'pushd', 'pwd', 'readonly',
   132             'logname', 'lp', 'lpr', 'ls', 'lsattr', 'lsmod', 'lsmod.old',
   126 			'return', 'shift', 'shopt', 'source', 'suspend', 'test', 'times',
   133             'lspci', 'ltrace', 'lynx',
   127 			'trap', 'type', 'typeset', 'ulimit', 'umask', 'unalias', 'unset',
   134 
   128 			'wait'
   135             'm4', 'make', 'man', 'mapscrn', 'mesg', 'mkdir', 'mkfifo',
   129 			)
   136             'mknod', 'mktemp', 'more', 'mount', 'mplayer', 'msgfmt', 'mv',
   130 		),
   137 
   131 	'SYMBOLS' => array(
   138             'namei', 'nano', 'nasm', 'nawk', 'netstat', 'nice',
   132 		'(', ')', '[', ']', '!', '@', '%', '&', '*', '|', '/', '<', '>', ';;'
   139             'nisdomainname', 'nl', 'nm', 'nm86', 'nmap', 'nohup', 'nop',
   133 		),
   140 
   134 	'CASE_SENSITIVE' => array(
   141             'od', 'openvt',
   135 		GESHI_COMMENTS => false,
   142 
   136 		1 => true,
   143             'passwd', 'patch', 'pcregrep', 'pcretest', 'perl', 'perror',
   137 		2 => true,
   144             'pgawk', 'pidof', 'ping', 'pr', 'procmail', 'prune', 'ps', 'pstree',
   138 		3 => true
   145             'ps2ascii', 'ps2epsi', 'ps2frag', 'ps2pdf', 'ps2ps', 'psbook',
   139 		),
   146             'psmerge', 'psnup', 'psresize', 'psselect', 'pstops',
   140 	'STYLES' => array(
   147 
   141 		'KEYWORDS' => array(
   148             'rbash', 'rcs', 'rcs2log', 'read', 'readlink', 'red', 'resizecons',
   142 			1 => 'color: #000000; font-weight: bold;',
   149             'rev', 'rm', 'rmdir', 'rsh', 'run-parts',
   143 			2 => 'color: #c20cb9; font-weight: bold;',
   150 
   144 			3 => 'color: #7a0874; font-weight: bold;'
   151             'sash', 'scp', 'screen', 'sed', 'seq', 'sendmail', 'setfont',
   145 			),
   152             'setkeycodes', 'setleds', 'setmetamode', 'setserial', 'setterm',
   146 		'COMMENTS' => array(
   153             'sh', 'showkey', 'shred', 'size', 'size86', 'skill', 'sleep',
   147 			1 => 'color: #808080; font-style: italic;'
   154             'slogin', 'snice', 'sort', 'sox', 'split', 'ssed', 'ssh', 'ssh-add',
   148 			),
   155             'ssh-agent', 'ssh-keygen', 'ssh-keyscan', 'stat', 'strace',
   149 		'ESCAPE_CHAR' => array(
   156             'strings', 'strip', 'stty', 'su', 'sudo', 'suidperl', 'sum', 'svn',
   150 			0 => 'color: #000099; font-weight: bold;'
   157             'svnadmin', 'svndumpfilter', 'svnlook', 'svnmerge', 'svnmucc',
   151 			),
   158             'svnserve', 'svnshell', 'svnsync', 'svnversion', 'svnwrap', 'sync',
   152 		'BRACKETS' => array(
   159 
   153 			0 => 'color: #7a0874; font-weight: bold;'
   160             'tac', 'tail', 'tar', 'tee', 'tempfile', 'touch', 'tr', 'tree',
   154 			),
   161             'true',
   155 		'STRINGS' => array(
   162 
   156 			0 => 'color: #ff0000;'
   163             'umount', 'uname', 'unicode_start', 'unicode_stop', 'uniq',
   157 			),
   164             'unlink', 'unzip', 'updatedb', 'updmap', 'uptime', 'users',
   158 		'NUMBERS' => array(
   165             'utmpdump', 'uuidgen',
   159 			0 => 'color: #000000;'
   166 
   160 			),
   167             'valgrind', 'vdir', 'vi', 'vim', 'vmstat',
   161 		'METHODS' => array(
   168 
   162 			),
   169             'w', 'wall', 'wc', 'wget', 'whatis', 'whereis', 'which', 'whiptail',
   163 		'SYMBOLS' => array(
   170             'who', 'whoami', 'write',
   164 			0 => 'color: #000000; font-weight: bold;'
   171 
   165 			),
   172             'xargs', 'xhost', 'xmodmap', 'xset',
   166 		'REGEXPS' => array(
   173 
   167 			0 => 'color: #007800;',
   174             'yacc', 'yes', 'ypdomainname',
   168 			1 => 'color: #007800;',
   175 
   169 			2 => 'color: #007800;',
   176             'zcat', 'zcmp', 'zdiff', 'zdump', 'zegrep', 'zfgrep', 'zforce',
   170 			3 => 'color: #808080; font-style: italic;',
   177             'zgrep', 'zip', 'zipgrep', 'zipinfo', 'zless', 'zmore', 'znew',
   171 			4 => 'color: #007800;'
   178             'zsh', 'zsoelim'
   172 			),
   179             ),
   173 		'SCRIPT' => array(
   180         3 => array(
   174 			)
   181             'alias', 'bg', 'bind', 'break', 'builtin', 'cd', 'command',
   175 		),
   182             'compgen', 'complete', 'continue', 'declare', 'dirs', 'disown',
   176 	'URLS' => array(
   183             'echo', 'enable', 'eval', 'exec', 'exit', 'export', 'fc',
   177 		1 => '',
   184             'fg', 'getopts', 'hash', 'help', 'history', 'jobs', 'let',
   178 		2 => '',
   185             'local', 'logout', 'popd', 'printf', 'pushd', 'pwd', 'readonly',
   179 		3 => ''
   186             'return', 'shift', 'shopt', 'source', 'suspend', 'test', 'times',
   180 	),
   187             'trap', 'type', 'typeset', 'ulimit', 'umask', 'unalias', 'unset',
   181 	'OOLANG' => false,
   188             'wait'
   182 	'OBJECT_SPLITTERS' => array(
   189             )
   183 		),
   190         ),
   184 	'REGEXPS' => array(
   191     'SYMBOLS' => array(
   185 		0 => "\\$\\{[a-zA-Z_][a-zA-Z0-9_]*?\\}",
   192         '(', ')', '[', ']', '!', '@', '%', '&', '*', '|', '/', '<', '>', ';;', '`'
   186 		1 => "\\$[a-zA-Z_][a-zA-Z0-9_]*",
   193         ),
   187 		2 => "([a-zA-Z_][a-zA-Z0-9_]*)=",
   194     'CASE_SENSITIVE' => array(
   188 		3 => "(?<!\\$)#[^\n]*",
   195         GESHI_COMMENTS => false,
   189 		4 => "\\$#"
   196         1 => true,
   190 		),
   197         2 => true,
   191 	'STRICT_MODE_APPLIES' => GESHI_NEVER,
   198         3 => true
   192 	'SCRIPT_DELIMITERS' => array(
   199         ),
   193 		),
   200     'STYLES' => array(
   194 	'HIGHLIGHT_STRICT_BLOCK' => array(
   201         'KEYWORDS' => array(
   195 		)
   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             0 => 'color: #666666; font-style: italic;',
       
   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             0 => 'color: #7a0874; font-weight: bold;'
       
   222             ),
       
   223         'STRINGS' => array(
       
   224             0 => 'color: #ff0000;',
       
   225             'HARD' => 'color: #ff0000;'
       
   226             ),
       
   227         'NUMBERS' => array(
       
   228             0 => 'color: #000000;'
       
   229             ),
       
   230         'METHODS' => array(
       
   231             ),
       
   232         'SYMBOLS' => array(
       
   233             0 => 'color: #000000; font-weight: bold;'
       
   234             ),
       
   235         'REGEXPS' => array(
       
   236             0 => 'color: #007800;',
       
   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         0 => "\\$\\{[a-zA-Z_][a-zA-Z0-9_]*?\\}",
       
   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             'DISALLOWED_AFTER' =>  "(?![\.\-a-zA-Z0-9_%])"
       
   278         )
       
   279     )
   196 );
   280 );
   197 
   281 
   198 ?>
   282 ?>