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