add -a to ls (now that there are dot files)

This commit is contained in:
Lisa Milne 2023-11-26 14:28:24 +10:00
parent 39ebcdc049
commit abf74e32c0

View file

@ -36,6 +36,7 @@ Use view or less to view the content, eg: view web/about
clite.commands.load('ls',function(args,env,io) {
var dirs = [];
var long = false;
var all = false;
var stdlib = io.include('stdlib');
var stdio = io.include('stdio');
function help() {
@ -46,6 +47,7 @@ Usage: ls [OPTION] [FILE]
Options:
-? Print this help information
-l Display data in long format
-a Do not ignore entries starting with .
`);
}
@ -75,6 +77,9 @@ Options:
case 'l':
long = true;
break;
case 'a':
all = true;
break;
default:
stdio.write(io.stderr,'unknown argument: -'+args[i][j]);
}
@ -103,6 +108,8 @@ Options:
}
var e;
while ((e = stdio.read(fd)) != null) {
if (e[0] == '.' && !all)
continue;
var efd = stdio.open(dir+'/'+e,false,true);
if (!efd) {
stdio.write(io.stderr,'cannot read contents: '+dir);