You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.3 KiB

7 months ago
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/5/LICENSE
  3. (function() {
  4. var mode = CodeMirror.getMode({}, "shell");
  5. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  6. MT("var",
  7. "text [def $var] text");
  8. MT("varBraces",
  9. "text[def ${var}]text");
  10. MT("varVar",
  11. "text [def $a$b] text");
  12. MT("varBracesVarBraces",
  13. "text[def ${a}${b}]text");
  14. MT("singleQuotedVar",
  15. "[string 'text $var text']");
  16. MT("singleQuotedVarBraces",
  17. "[string 'text ${var} text']");
  18. MT("doubleQuotedVar",
  19. '[string "text ][def $var][string text"]');
  20. MT("doubleQuotedVarBraces",
  21. '[string "text][def ${var}][string text"]');
  22. MT("doubleQuotedVarPunct",
  23. '[string "text ][def $@][string text"]');
  24. MT("doubleQuotedVarVar",
  25. '[string "][def $a$b][string "]');
  26. MT("doubleQuotedVarBracesVarBraces",
  27. '[string "][def ${a}${b}][string "]');
  28. MT("notAString",
  29. "text\\'text");
  30. MT("escapes",
  31. "outside\\'\\\"\\`\\\\[string \"inside\\`\\'\\\"\\\\`\\$notAVar\"]outside\\$\\(notASubShell\\)");
  32. MT("subshell",
  33. "[builtin echo] [quote $(whoami)] s log, stardate [quote `date`].");
  34. MT("doubleQuotedSubshell",
  35. "[builtin echo] [string \"][quote $(whoami)][string 's log, stardate `date`.\"]");
  36. MT("hashbang",
  37. "[meta #!/bin/bash]");
  38. MT("comment",
  39. "text [comment # Blurb]");
  40. MT("numbers",
  41. "[number 0] [number 1] [number 2]");
  42. MT("keywords",
  43. "[keyword while] [atom true]; [keyword do]",
  44. " [builtin sleep] [number 3]",
  45. "[keyword done]");
  46. MT("options",
  47. "[builtin ls] [attribute -l] [attribute --human-readable]");
  48. MT("operator",
  49. "[def var][operator =]value");
  50. MT("doubleParens",
  51. "foo [quote $((bar))]")
  52. MT("nested braces",
  53. "[builtin echo] [def ${A[${B}]]}]")
  54. MT("strings in parens",
  55. "[def FOO][operator =]([quote $(<][string \"][def $MYDIR][string \"][quote /myfile grep ][string 'hello$'][quote )])")
  56. MT("string ending in dollar",
  57. '[def a][operator =][string "xyz$"]; [def b][operator =][string "y"]')
  58. MT("quote ending in dollar",
  59. "[quote $(echo a$)]")
  60. MT("heredoc",
  61. "[builtin cat] [string-2 <<- end]",
  62. "[string-2 content one]",
  63. "[string-2 content two end]",
  64. "[string-2 end]",
  65. "[builtin echo]")
  66. })();