: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
})(function(CodeMirror) {
CodeMirror.defineMode('shell', function() {
function define(style, string) {
var split = string.split(' ');
for(var i = 0; i < split.length; i++) {
define('atom', 'true false');
define('keyword', 'if then do else elif while until for in esac fi fin ' +
'fil done exit set unset export function');
define('builtin', 'ab awk bash beep cat cc cd chown chmod chroot clear cp ' +
'curl cut diff echo find gawk gcc get git grep kill killall ln ls make ' +
'mkdir openssl mv nc node npm ping ps restart rm rmdir sed service sh ' +
'shopt shred source sort sleep ssh start stop su sudo tee telnet top ' +
'touch vi vim wall wc wget who write yes zsh');
function tokenBase(stream, state) {
if (stream.eatSpace()) return null;
if (ch === '\'' || ch === '"' || ch === '`') {
state.tokens.unshift(tokenString(ch));
return tokenize(stream, state);
if (sol && stream.eat('!')) {
return 'meta'; // 'comment'?
state.tokens.unshift(tokenDollar);
return tokenize(stream, state);
if (ch === '+' || ch === '=') {
if(stream.eol() || !/\w/.test(stream.peek())) {
stream.eatWhile(/[\w-]/);
var cur = stream.current();
if (stream.peek() === '=' && /\w+/.test(cur)) return 'def';
return words.hasOwnProperty(cur) ? words[cur] : null;
function tokenString(quote) {
return function(stream, state) {
var next, end = false, escaped = false;
while ((next = stream.next()) != null) {
if (next === quote && !escaped) {
if (next === '$' && !escaped && quote !== '\'') {
state.tokens.unshift(tokenDollar);
escaped = !escaped && next === '\\';
return (quote === '`' || quote === ')' ? 'quote' : 'string');
var tokenDollar = function(stream, state) {
if (state.tokens.length > 1) stream.eat('$');
var ch = stream.next(), hungry = /\w/;
if (ch === '{') hungry = /[^}]/;
state.tokens[0] = tokenString(')');
return tokenize(stream, state);
function tokenize(stream, state) {
return (state.tokens[0] || tokenBase) (stream, state);
startState: function() {return {tokens:[]};},
token: function(stream, state) {
return tokenize(stream, state);
CodeMirror.defineMIME('text/x-sh', 'shell');