blash/commands/cd.json

44 lines
699 B
JSON
Raw Normal View History

2010-12-22 02:28:45 +01:00
{
"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;
2010-12-23 14:25:43 +01:00
arg = shell.expandPath ( arg );
2010-12-22 02:28:45 +01:00
for ( var i=0; i < shell.files.length && !found; i++ )
2010-12-22 02:28:45 +01:00
{
if ( shell.files[i].path == arg )
2010-12-22 02:28:45 +01:00
{
found = true;
if ( shell.files[i].type != 'directory' )
2010-12-22 02:28:45 +01:00
{
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;
},
}