Compare commits

...

2 Commits

Author SHA1 Message Date
b1ek 3e3553fd81
fix ,* filtering in ls 2023-03-20 21:04:07 +10:00
b1ek bf501ededa
use \t for displaying ls output 2023-03-20 21:02:34 +10:00
1 changed files with 5 additions and 6 deletions

View File

@ -23,10 +23,6 @@ module.exports = (argv, terminal) => {
const long_format = has_arg('-l');
directories.shift();
// remove .* files if -a not specified
if (!all)
directories = directories.filter(x => !x.startsWith('.'));
// remove arguments
directories = directories.filter(x => !x.startsWith('-'));
@ -52,11 +48,14 @@ module.exports = (argv, terminal) => {
terminal.writeln(`${argv[0]}: cannot access '${dir}': No such file or directory`);
return;
}
let files = fs.readdirSync(dir);
let files = ['.', '..', ...fs.readdirSync(dir)];
if (!all)
files = files.filter(x => !x.startsWith('.'));
files.forEach((file, i) => {
if (!long_format)
terminal.write(file + '\033[0m ');
terminal.write(file + '\033[0m\t');
else
terminal.writeln('drwx-xr-x 1 nobody nobody 4.0K Jan 1 13 01:00 ' + file);
if ((i+1) % 5 == 0)