!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("shell",function(){var t={};function n(e,n){for(var r=0;r<n.length;r++)t[n[r]]=e}var r=["true","false"],i=["if","then","do","else","elif","while","until","for","in","esac","fi","fin","fil","done","exit","set","unset","export","function"],o=["ab","awk","bash","beep","cat","cc","cd","chown","chmod","chroot","clear","cp","curl","cut","diff","echo","find","gawk","gcc","get","git","grep","hg","kill","killall","ln","ls","make","mkdir","openssl","mv","nc","nl","node","npm","ping","ps","restart","rm","rmdir","sed","service","sh","shopt","shred","source","sort","sleep","ssh","start","stop","su","sudo","svn","tee","telnet","top","touch","vi","vim","wall","wc","wget","who","write","yes","zsh"];function s(e,t){var n="("==e?")":"{"==e?"}":e;return function(r,i){for(var o,c=!1;null!=(o=r.next());){if(o===n&&!c){i.tokens.shift();break}if("$"===o&&!c&&"'"!==e&&r.peek()!=n){c=!0,r.backUp(1),i.tokens.unshift(f);break}if(!c&&e!==n&&o===e)return i.tokens.unshift(s(e,t)),l(r,i);if(!c&&/['"]/.test(o)&&!/['"]/.test(e)){i.tokens.unshift(u(o,"string")),r.backUp(1);break}c=!c&&"\\"===o}return t}}function u(e,t){return function(n,r){return r.tokens[0]=s(e,t),n.next(),l(n,r)}}e.registerHelper("hintWords","shell",r.concat(i,o)),n("atom",r),n("keyword",i),n("builtin",o);var f=function(e,t){t.tokens.length>1&&e.eat("$");var n=e.next();return/['"({]/.test(n)?(t.tokens[0]=s(n,"("==n?"quote":"{"==n?"def":"string"),l(e,t)):(/\d/.test(n)||e.eatWhile(/\w/),t.tokens.shift(),"def")};function l(e,n){return(n.tokens[0]||function(e,n){if(e.eatSpace())return null;var r,i=e.sol(),o=e.next();if("\\"===o)return e.next(),null;if("'"===o||'"'===o||"`"===o)return n.tokens.unshift(s(o,"`"===o?"quote":"string")),l(e,n);if("#"===o)return i&&e.eat("!")?(e.skipToEnd(),"meta"):(e.skipToEnd(),"comment");if("$"===o)return n.tokens.unshift(f),l(e,n);if("+"===o||"="===o)return"operator";if("-"===o)return e.eat("-"),e.eatWhile(/\w/),"attribute";if("<"==o){if(e.match("<<"))return"operator";var u=e.match(/^<-?\s*['"]?([^'"]*)['"]?/);if(u)return n.tokens.unshift((r=u[1],function(e,t){return e.sol()&&e.string==r&&t.tokens.shift(),e.skipToEnd(),"string-2"})),"string-2"}if(/\d/.test(o)&&(e.eatWhile(/\d/),e.eol()||!/\w/.test(e.peek())))return"number";e.eatWhile(/[\w-]/);var c=e.current();return"="===e.peek()&&/\w+/.test(c)?"def":t.hasOwnProperty(c)?t[c]:null})(e,n)}return{startState:function(){return{tokens:[]}},token:function(e,t){return l(e,t)},closeBrackets:"()[]{}''\"\"``",lineComment:"#",fold:"brace"}}),e.defineMIME("text/x-sh","shell"),e.defineMIME("application/x-sh","shell")});