var f={};function c(e,t){for(var r=0;r<t.length;r++)f[t[r]]=e}var l=["true","false"],k=["if","then","do","else","elif","while","until","for","in","esac","fi","fin","fil","done","exit","set","unset","export","function"],h="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".split(".");c("atom",l),c("keyword",k),c("builtin",h);function d(e,t){if(e.eatSpace())return null;var r=e.sol(),n=e.next();if(n==="\\")return e.next(),null;if(n==="'"||n==='"'||n==="`")return t.tokens.unshift(a(n,n==="`"?"quote":"string")),u(e,t);if(n==="#")return r&&e.eat("!")?(e.skipToEnd(),"meta"):(e.skipToEnd(),"comment");if(n==="$")return t.tokens.unshift(p),u(e,t);if(n==="+"||n==="=")return"operator";if(n==="-")return e.eat("-"),e.eatWhile(/\w/),"attribute";if(n=="<"){if(e.match("<<"))return"operator";var i=e.match(/^<-?\s*(?:['"]([^'"]*)['"]|([^'"\s]*))/);if(i)return t.tokens.unshift(g(i[1]||i[2])),"string.special"}if(/\d/.test(n)&&(e.eatWhile(/\d/),e.eol()||!/\w/.test(e.peek())))return"number";e.eatWhile(/[\w-]/);var s=e.current();return e.peek()==="="&&/\w+/.test(s)?"def":f.hasOwnProperty(s)?f[s]:null}function a(e,t){var r=e=="("?")":e=="{"?"}":e;return function(n,i){for(var s,o=!1;(s=n.next())!=null;){if(s===r&&!o){i.tokens.shift();break}else if(s==="$"&&!o&&e!=="'"&&n.peek()!=r){o=!0,n.backUp(1),i.tokens.unshift(p);break}else{if(!o&&e!==r&&s===e)return i.tokens.unshift(a(e,t)),u(n,i);if(!o&&/['"]/.test(s)&&!/['"]/.test(e)){i.tokens.unshift(m(s,"string")),n.backUp(1);break}}o=!o&&s==="\\"}return t}}function m(e,t){return function(r,n){return n.tokens[0]=a(e,t),r.next(),u(r,n)}}var p=function(e,t){t.tokens.length>1&&e.eat("$");var r=e.next();return/['"({]/.test(r)?(t.tokens[0]=a(r,r=="("?"quote":r=="{"?"def":"string"),u(e,t)):(/\d/.test(r)||e.eatWhile(/\w/),t.tokens.shift(),"def")};function g(e){return function(t,r){return t.sol()&&t.string==e&&r.tokens.shift(),t.skipToEnd(),"string.special"}}function u(e,t){return(t.tokens[0]||d)(e,t)}const w={name:"shell",startState:function(){return{tokens:[]}},token:function(e,t){return u(e,t)},languageData:{autocomplete:l.concat(k,h),closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"#"}}};export{w as t};
