should not be able to cd into a file

This commit is contained in:
Lisa Milne 2023-11-12 20:23:13 +10:00
parent 45b03465c3
commit 221599955a

View file

@ -1317,11 +1317,15 @@ clite.shell = {
if (args.length > 1) {
dir = clite.lib.resolvePath(args[1]);
}
var fd = clite.io.open(dir);
var fd = clite.io.open(dir,false);
if (!fd) {
io.error('invalid directory: '+dir);
return;
}
if (!fd.node.data.isdir) {
io.error('invalid directory: '+dir);
return;
}
clite.io.close(fd);
clite.shell.env.PWD = dir;
clite.shell.prompt.generate();
@ -1341,7 +1345,7 @@ clite.shell = {
return;
}else{
var path = clite.shell.resolvePath(args[1]);
var fd = clite.io.open(path);
var fd = clite.io.open(path,false);
if (!fd)
return;
clite.io.close(fd);
@ -1355,7 +1359,7 @@ clite.shell = {
io.write(args[1]+' is a shell builtin');
}else{
var path = clite.shell.resolvePath(args[1]);
var fd = clite.io.open(path);
var fd = clite.io.open(path,false);
if (!fd)
return;
clite.io.close(fd);