43 lines
732 B
JSON
43 lines
732 B
JSON
{
|
|
"name" : "cd",
|
|
|
|
"info" : {
|
|
"syntax" : "cd <directory>",
|
|
"brief" : "Change the current directory to the specified one",
|
|
},
|
|
|
|
"action" : function ( arg )
|
|
{
|
|
var out = '';
|
|
|
|
if ( !arg || arg.length == 0 )
|
|
{
|
|
return "Parameter expected<br/>\n";
|
|
}
|
|
|
|
var found = false;
|
|
arg = shell.expandPath ( arg );
|
|
|
|
for ( var i=0; i < shell.json.directories.length && !found; i++ )
|
|
{
|
|
if ( shell.json.directories[i].path == arg )
|
|
{
|
|
found = true;
|
|
|
|
if ( shell.json.directories[i].type != 'directory' )
|
|
{
|
|
return "cd: not a directory: " + arg + "<br/>\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( !found )
|
|
{
|
|
return "cd: no such file or directory: " + arg + "<br/>\n";
|
|
}
|
|
|
|
shell.path = arg;
|
|
return out;
|
|
},
|
|
}
|
|
|