sh.jsf.in (5747B)
1 # JOE syntax highlight file for sh/ksh/bash 2 3 # Think about: 4 # $'....' 5 # $(...) 6 # ${...} 7 8 # cat <<EOF xxxxxx 9 # xxxxx should be interpreted as other arguments for 'cat'. 10 11 # Colors 12 13 =Idle 14 =Comment green 15 =Constant cyan 16 =Escape bold cyan 17 =Keyword bold 18 =Var magenta 19 20 # Syntax 21 22 :idle Idle 23 * idle 24 # ")" subst_char recolor=-1 25 "`" subst_char recolor=-1 26 "#" comment recolor=-1 27 "\\" escape recolor=-1 28 "$" subst recolor=-1 29 "'" string_sq recolor=-1 30 "\"" string_dq recolor=-1 31 "<" maybe_inc 32 "0-9" maybe_base recolor=-1 33 "a-zA-Z{}![_" ident buffer 34 35 :subst_char Var 36 * idle noeat 37 38 :maybe_inc Idle 39 * idle noeat 40 "<" maybe_inc1 41 42 :maybe_inc1 Idle 43 * inc buffer noeat 44 "\"" inc_quote 45 "'" inc_quote 46 " " maybe_inc1 47 "\n" toeof 48 "`&()\\|;<>" idle noeat 49 "\\" skipquote 50 "-" skipminus 51 52 :skipminus Idle 53 * inc1 buffer noeat 54 " " skipminus 55 "\\" skipquote 56 "\"" inc1_quote 57 "'" inc1_quote 58 "`&()\\|;<>\n" idle noeat 59 60 :skipquote Idle 61 * inc buffer noeat 62 "`&()\\|;'\"<> \n" idle noeat 63 64 # All of these are for case of leading - 65 66 :inc1 Var 67 * inc1 68 "`&()\\|;'\"<> \n" skipline1 noeat save_s 69 70 :inc1_quote Var 71 * inc1 buffer noeat 72 73 :skipline1 Idle 74 * skipline1 75 "\n" next_line1 76 77 :todelim1 Constant 78 * todelim1 79 "\n" next_line1 strings 80 "&" founddelim1 81 done 82 83 :next_line1 Constant 84 * todelim1 buffer 85 "\t" next_line1 86 "\n" next_line1 87 88 :founddelim1 Var 89 * idle noeat 90 91 # No leading - 92 93 :inc Var 94 * inc 95 "`&()\\|;'\"<> \n" skipline noeat save_s 96 97 :inc_quote Var 98 * inc noeat buffer 99 100 # Should be treated as a normal line here... 101 102 :skipline Idle 103 * skipline 104 "\n" next_line 105 106 :todelim Constant 107 * todelim 108 "\n" next_line strings 109 "&" founddelim 110 done 111 112 # eat \n so it's not in string. 113 :next_line Constant 114 * todelim buffer 115 "\n" next_line 116 117 :founddelim Var 118 * idle noeat 119 120 # << with no word. Rest of file is a constant. 121 122 :toeof Constant 123 * toeof 124 125 :comment Comment comment 126 * comment 127 "\n" idle 128 129 :escape Escape 130 * idle 131 132 :subst Var 133 * idle noeat 134 "(" idle recolor=-2 # don't try for now 135 "\"" string_dq recolor=-2 136 "\'" string_sq recolor=-2 137 "{" subst_brack 138 "a-zA-Z_" subst_name 139 "0-9*@?\-$_!#" idle 140 141 :subst_name Var 142 * idle noeat recolor=-1 143 "a-zA-Z0-9_" subst_name 144 145 :subst_brack Var 146 * subst_brack 147 "}" idle 148 149 # Simplest case: no quoting allowed 150 :string_sq Constant string 151 * string_sq 152 "\'" idle 153 154 155 # double-quote: quoting, backqoutes and substitution allowed 156 :string_dq Constant string 157 * string_dq 158 "$" string_dq_subst recolor=-1 159 "\"" idle 160 "\\" string_dq_esc recolor=-1 161 "`" string_dq_bq recolor=-1 162 163 :string_dq_subst Var string 164 * string_dq noeat recolor=-2 165 "$0-9!_\-?*@" string_dq 166 "a-zA-Z_" string_dq_subst_name 167 "{" string_dq_subst_brack 168 169 :string_dq_subst_name Var string 170 * string_dq recolor=-1 noeat 171 "a-zA-Z0-9_" string_dq_subst_name 172 173 :string_dq_subst_brack Var string 174 * string_dq_subst_brack 175 "}" string_dq 176 177 :string_dq_esc Escape string 178 * string_dq recolor=-2 179 "$`\"\\" string_dq 180 "\n" string_dq recolor=-2 181 182 :string_dq_bq Constant string 183 * string_dq_bq 184 "$" string_dq_bq_subst recolor=-1 185 "\`" string_dq 186 "\\" string_dq_bq_esc recolor=-1 187 188 :string_dq_bq_subst Var string 189 * string_dq_bq noeat recolor=-2 190 "$0-9!_\-?*@" string_dq_bq 191 "a-zA-Z_" string_dq_bq_subst_name 192 "{" string_dq_bq_subst_brack 193 194 :string_dq_bq_subst_name Var string 195 * string_dq_bq recolor=-1 noeat 196 "a-zA-Z0-9_" string_dq_bq_subst_name 197 198 :string_dq_bq_subst_brack Var string 199 * string_dq_bq_subst_brack 200 "}" string_dq_bq 201 202 :string_dq_bq_esc Escape string 203 * string_dq_bq recolor=-2 204 "$`\"\\" string_dq_bq 205 "\n" string_dq_bq recolor=-2 206 207 208 # backquote 209 :string_bq Constant 210 * string_bq 211 "$" string_bq_subst recolor=-1 212 "\`" idle 213 "\\" string_bq_esc recolor=-1 214 215 # escape in backquote 216 :string_bq_esc Escape 217 * string_bq recolor=-2 218 "$`\"\\" string_bq 219 "\n" string_bq recolor=-2 220 221 # Substitution in a backquote 222 :string_bq_subst Var 223 * string_bq noeat recolor=-2 224 "$0-9!_\-?*@" string_bq 225 "a-zA-Z_" string_bq_subst_name 226 "{" string_bq_subst_brack 227 228 :string_bq_subst_name Var 229 * string_bq recolor=-1 noeat 230 "a-zA-Z0-9_" string_bq_subst_name 231 232 :string_bq_subst_brack Var 233 * string_bq_subst_brack 234 "}" string_bq 235 236 :maybe_base Idle 237 * idle noeat 238 "#" idle 239 "0-9" maybe_base 240 241 :ident Idle 242 * idle noeat strings 243 "!" bang 244 "{" kw 245 "}" kw 246 "[" kw 247 "]" kw 248 # primary keywords 249 "case" kw 250 "do" kw 251 "done" kw 252 "elif" kw 253 "else" kw 254 "esac" kw 255 "fi" kw 256 "for" kw 257 "if" kw 258 "in" kw 259 "then" kw 260 "until" kw 261 "while" kw 262 # I think these are basically keywords too 263 "break" kw 264 "continue" kw 265 "return" kw 266 "eval" kw 267 "exec" kw 268 "exit" kw 269 "test" kw # doesn't have to be a shell command 270 # variable management 271 "shift" kw 272 "unset" kw 273 "export" kw 274 "readonly" kw 275 # input 276 "read" kw 277 # job control (not likely to be used in scripts) 278 "bg" kw 279 "fg" kw 280 "jobs" kw 281 "suspend" kw 282 # job control (useful in scripts) 283 "kill" kw 284 "wait" kw 285 # environment control 286 "cd" kw 287 "chdir" kw 288 "pwd" kw 289 "ulimit" kw 290 "umask" kw 291 # signal handling 292 "trap" kw 293 # misc shell control 294 "hash" kw 295 "type" kw 296 "times" kw 297 "set" kw 298 # shell builtins 299 "echo" kw 300 "getopts" kw 301 "login" kw # not bash (logout is) 302 "newgrp" kw # not in bash 303 "stop" kw # not in bash (suspends a process) 304 # additional ksh builtins 305 "alias" kw 306 "select" kw 307 "function" kw 308 "command" kw 309 "fc" kw 310 "let" kw 311 "print" kw 312 "unalias" kw 313 "whence" kw 314 "history" kw 315 "time" kw 316 "typeset" kw 317 "local" kw 318 # additional bash builtins 319 "source" kw 320 "bind" kw 321 "builtin" kw 322 "compgen" kw 323 "complete" kw 324 "declare" kw 325 "dirs" kw 326 "disown" kw 327 "enable" kw 328 "help" kw 329 "logout" kw 330 "popd" kw 331 "printf" kw 332 "pushd" kw 333 "shopt" kw 334 done 335 "a-zA-Z0-9_" ident 336 337 :kw Keyword 338 * idle noeat 339 340 :bang Keyword 341 * idle noeat 342 "#" idle 343 "!" bang