"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/langDefs/sh.lang" (12 May 2020, 3387 Bytes) of package /windows/www/highlight-3.57-x64.zip:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "sh.lang": 3.53_vs_3.54.

    1 
    2 Description="Bash"
    3 
    4 Categories = {"script", "shell"}
    5 
    6 Identifiers=[[ [a-zA-Z_][\w\-]*(?!\/) ]]
    7 
    8 Keywords={
    9   { Id=1,
   10     List={"case", "in", "esac", "for", "do", "done", "function", "if", "then",
   11         "fi", "elif", "else", "select", "time", "until", "while"},
   12   },
   13   { Id=2,
   14     List={"source", "alias", "bind", "break", "builtin", "command", "continue",
   15         "declare", "dirs", "disown", "enable", "export", "fc", "fg", "getopts",
   16         "hash", "help", "history", "jobs",  "let", "local", "logout", "popd", "printf",
   17         "pushd", "pwd", "read", "readonly", "return", "set",  "shift", "shopt",
   18         "suspend", "test", "times", "trap", "type", "ulimit", "umask", "unalias",
   19         "unset", "wait", "eval", "bg", "cd", "echo", "exec", "exit", "kill"},
   20   },
   21   { Id=3,
   22     List={"ls", "cat", "tac", "rev", "cp", "mv", "rm", "rmdir", "chmod",
   23         "chattr", "ln", "find", "xargs", "expr", "date", "zdump", "time", "touch", "at",
   24         "batch", "cal", "sleep", "usleep", "hwclock", "clock", "sort", "tsort", "diff",
   25         "patch", "diff3", "sdiff", "cmp", "comm", "uniq", "expand", "unexpand", "cat",
   26         "paste", "join", "head", "tail", "grep", "egrep", "zgrep", "look", "sed", "awk",
   27         "wc", "tr", "fold", "fmt", "ptx", "col", "column", "colrm", "nl", "pr",
   28         "gettext", "iconv", "recode", "groff", "lex", "yacc", "tar", "shar", "ar",
   29         "cpio", "gzip", "bzip2", "compress", "uncompress", "zip", "unzip", "sq", "file",
   30         "which", "whereis", "whatis", "vdir", "shred", "locate", "slocate", "strings",
   31         "basename", "dirname", "split", "sum", "cksum", "md5sum", "sha1sum", "uuencode",
   32         "uudecode", "crypt", "make", "install", "more", "less", "host", "vrfy",
   33         "nslookup", "dig", "traceroute", "ping", "whois", "finger", "ftp", "uucp",
   34         "telnet", "rlogin", "rsh", "rcp", "ssh", "write", "mail", "vacation", "tput",
   35         "reset", "clear", "script", "factor", "bc", "dc", "jot", "seq", "yes", "banner",
   36         "printenv", "lp", "tee", "mkfifo", "pathchk", "dd", "od", "hexdump", "m4"},
   37   },
   38 
   39   -- fixes issue with expressions like ${SHELL="${CONFIG_SHELL-/bin/sh}"}
   40   -- the [^\}]+ part fixes issue with "s#@PATH@#/opt/${pkgname}/bin/# ${pkgdir}/etc/profile.d/${pkgname}.sh"
   41   { Id=4,
   42     Regex=[[\$\{[^\}]+\$\{.+?\}.+?\}|\$\{.+?\} ]],
   43   },
   44   { Id=4,
   45     Regex=[[ \$[\w\#]+ ]],
   46   },
   47   { Id=2,
   48     Regex=[[ \-\-?[\w\-]+ ]],
   49   },
   50 
   51   --see OnStateChange
   52   { Id=5,
   53     Regex=[[ \*\[.*?\]\* ]],
   54   }
   55 }
   56 
   57 -- hereDoc opening delimiter, see OnStateChange to handle end of string
   58 Strings={
   59   Delimiter=[[<<[\-]?\s*["']?\s*[A-Za-z_]+["']?|"|`|']],
   60 }
   61 
   62 IgnoreCase=false
   63 
   64 Comments={
   65   { Block=false,
   66     Delimiter= { [[#]] },
   67   },
   68 }
   69 
   70 Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\:|\&|<|>|\!|\=|\/|\*|\%|\+|\-|\|]]
   71 
   72 function OnStateChange(oldState, newState, token, kwClass)
   73 
   74   if oldState==HL_STRING and token==hereDoc then
   75     hereDoc = nil
   76     return HL_STRING_END
   77   end
   78 
   79   if  (string.sub(token,1,1) =="$" )  and oldState==HL_STRING and newState==HL_KEYWORD then
   80     return HL_INTERPOLATION
   81   end
   82 
   83   -- fix of code like case $1 in  *[\\\`\"\$]*)
   84   if  kwClass==5 then
   85     return HL_OPERATOR
   86   end
   87 
   88   if hereDoc~=nil then
   89     return HL_STRING
   90   end
   91 
   92   --recognize hereDoc multine strings
   93   if oldState==HL_STANDARD and newState==HL_STRING  then
   94     hereDoc = string.match(token, "<<%-?%s*%'?([%-%a%d_]+)" )
   95   end
   96 
   97   return newState
   98 end