diff --git a/blash.css b/blash.css index da4f52e..92bef25 100644 --- a/blash.css +++ b/blash.css @@ -66,3 +66,18 @@ span.brief color : green; } +span.filematch +{ + color : #672377; +} + +span.linematch +{ + color : #73d216; +} + +span.match +{ + color : #992010; +} + diff --git a/commands/logout.json b/commands/logout.json index 856b626..f3d597a 100644 --- a/commands/logout.json +++ b/commands/logout.json @@ -49,6 +49,29 @@ if ( http2.readyState == 4 && http2.status == 200 ) { shell.files = eval ( '(' + http2.responseText + ')' ); + + // Remove duplicates + var tmp = new Array(); + + for ( var i in shell.files ) + { + var contains = false; + + for ( var j=0; j < tmp.length && !contains; j++ ) + { + if ( shell.files[i].path == tmp[j].path ) + { + contains = true; + } + } + + if ( !contains ) + { + tmp.push ( shell.files[i] ); + } + } + + shell.files = tmp; } } diff --git a/commands/su.json b/commands/su.json index 07e5189..b1fc6f9 100644 --- a/commands/su.json +++ b/commands/su.json @@ -81,6 +81,29 @@ if ( http2.readyState == 4 && http2.status == 200 ) { shell.files = eval ( '(' + http2.responseText + ')' ); + + // Remove duplicates + var tmp = new Array(); + + for ( var i in shell.files ) + { + var contains = false; + + for ( var j=0; j < tmp.length && !contains; j++ ) + { + if ( shell.files[i].path == tmp[j].path ) + { + contains = true; + } + } + + if ( !contains ) + { + tmp.push ( shell.files[i] ); + } + } + + shell.files = tmp; } } diff --git a/system/blash.js b/system/blash.js index d159328..d6686ba 100644 --- a/system/blash.js +++ b/system/blash.js @@ -184,6 +184,29 @@ function blash () if ( http2.readyState == 4 && http2.status == 200 ) { shell.files = eval ( '(' + http2.responseText + ')' ); + + // Remove duplicates + var tmp = new Array(); + + for ( var i in shell.files ) + { + var contains = false; + + for ( var j=0; j < tmp.length && !contains; j++ ) + { + if ( shell.files[i].path == tmp[j].path ) + { + contains = true; + } + } + + if ( !contains ) + { + tmp.push ( shell.files[i] ); + } + } + + shell.files = tmp; } } @@ -618,8 +641,21 @@ function blash () return prompt; } + /** + * \brief Expand an argument as path, transforming it into an absolute path, removing extra slashes and expanding '..' notations + */ this.expandPath = function ( arg ) { + if ( !arg || arg.length == 0 ) + { + return false; + } + + while ( arg.match ( /(^|\/)\.\// )) + { + arg = arg.replace ( /(^|\/)\.\//, '/' ); + } + if ( arg.match ( /^[^\/]/ )) { arg = this.path + '/' + arg; @@ -656,5 +692,26 @@ function blash () return arg; } + + /** + * \brief Expand the star '*' notations inside of a path + */ + this.expandStar = function ( arg ) + { + arg = arg.replace ( /([^\\])?\*/g, '$1.*' ); + + var matches = new Array(); + var re = new RegExp ( arg ); + + for ( var i=0; i < this.files.length; i++ ) + { + if ( this.files[i].path.match ( re )) + { + matches.push ( this.files[i] ); + } + } + + return matches; + } } diff --git a/system/blash.json b/system/blash.json index 2625e17..b247238 100644 --- a/system/blash.json +++ b/system/blash.json @@ -59,6 +59,7 @@ "echo", "eval", "find", + "grep", "logout", "ls", "man", diff --git a/system/files_json.php b/system/files_json.php index 4197f6b..c0c879e 100644 --- a/system/files_json.php +++ b/system/files_json.php @@ -96,11 +96,6 @@ $files_json = <<