sh.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. ace.define("ace/snippets/sh",["require","exports","module"], function(require, exports, module) {
  2. "use strict";
  3. exports.snippetText = "# Shebang. Executing bash via /usr/bin/env makes scripts more portable.\n\
  4. snippet #!\n\
  5. #!/usr/bin/env bash\n\
  6. \n\
  7. snippet if\n\
  8. if [[ ${1:condition} ]]; then\n\
  9. ${2:#statements}\n\
  10. fi\n\
  11. snippet elif\n\
  12. elif [[ ${1:condition} ]]; then\n\
  13. ${2:#statements}\n\
  14. snippet for\n\
  15. for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do\n\
  16. ${3:#statements}\n\
  17. done\n\
  18. snippet fori\n\
  19. for ${1:needle} in ${2:haystack} ; do\n\
  20. ${3:#statements}\n\
  21. done\n\
  22. snippet wh\n\
  23. while [[ ${1:condition} ]]; do\n\
  24. ${2:#statements}\n\
  25. done\n\
  26. snippet until\n\
  27. until [[ ${1:condition} ]]; do\n\
  28. ${2:#statements}\n\
  29. done\n\
  30. snippet case\n\
  31. case ${1:word} in\n\
  32. ${2:pattern})\n\
  33. ${3};;\n\
  34. esac\n\
  35. snippet go \n\
  36. while getopts '${1:o}' ${2:opts} \n\
  37. do \n\
  38. case $$2 in\n\
  39. ${3:o0})\n\
  40. ${4:#staments};;\n\
  41. esac\n\
  42. done\n\
  43. # Set SCRIPT_DIR variable to directory script is located.\n\
  44. snippet sdir\n\
  45. SCRIPT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\n\
  46. # getopt\n\
  47. snippet getopt\n\
  48. __ScriptVersion=\"${1:version}\"\n\
  49. \n\
  50. #=== FUNCTION ================================================================\n\
  51. # NAME: usage\n\
  52. # DESCRIPTION: Display usage information.\n\
  53. #===============================================================================\n\
  54. function usage ()\n\
  55. {\n\
  56. cat <<- EOT\n\
  57. \n\
  58. Usage : $${0:0} [options] [--] \n\
  59. \n\
  60. Options: \n\
  61. -h|help Display this message\n\
  62. -v|version Display script version\n\
  63. \n\
  64. EOT\n\
  65. } # ---------- end of function usage ----------\n\
  66. \n\
  67. #-----------------------------------------------------------------------\n\
  68. # Handle command line arguments\n\
  69. #-----------------------------------------------------------------------\n\
  70. \n\
  71. while getopts \":hv\" opt\n\
  72. do\n\
  73. case $opt in\n\
  74. \n\
  75. h|help ) usage; exit 0 ;;\n\
  76. \n\
  77. v|version ) echo \"$${0:0} -- Version $__ScriptVersion\"; exit 0 ;;\n\
  78. \n\
  79. \\? ) echo -e \"\\n Option does not exist : $OPTARG\\n\"\n\
  80. usage; exit 1 ;;\n\
  81. \n\
  82. esac # --- end of case ---\n\
  83. done\n\
  84. shift $(($OPTIND-1))\n\
  85. \n\
  86. ";
  87. exports.scope = "sh";
  88. });