- chunking fixed
- bug with recursive ls looping fixed
- bug with empty directories on ls -a failing fixed
This commit is contained in:
2026-09-06 02:48:11 +02:00
parent b75e691a0b
commit e2ade5de29
3 changed files with 17 additions and 18 deletions
+10 -11
View File
@@ -210,24 +210,23 @@ async function main(io: CommandIO, state: ShellState, args: string[]): Promise<C
const session = getCurrentSession(state); const session = getCurrentSession(state);
// This needs fixing, separate paths into a separate array from args
if (paths.length === 0) { if (paths.length === 0) {
entries.push({ inode: session.cwd, path: "." }); entries.push({ inode: session.cwd, path: "." });
} else { } else {
for (const arg of args) { for (const path of paths) {
const inode = resolvePath(state, arg); const inode = resolvePath(state, path);
if (inode === -1) { if (inode === -1) {
return { return {
state, state,
result: createErrorResult( result: createErrorResult(
"PathResolutionError", "PathResolutionError",
`No such file or directory`, `No such file or directory`,
{ path: arg }, { path },
COMMAND_NAME, COMMAND_NAME,
), ),
}; };
} }
entries.push({ inode: inode, path: arg }); entries.push({ inode: inode, path });
} }
} }
@@ -259,8 +258,8 @@ async function main(io: CommandIO, state: ShellState, args: string[]): Promise<C
if (!options.all && !options.almostAll) children = children.filter(c => !c.name.startsWith(".")); if (!options.all && !options.almostAll) children = children.filter(c => !c.name.startsWith("."));
if (options.long) { if (options.long) {
longMode(io, state, children); longMode(io, state, children, node);
//io.writeStdout(e.encode("\n")); if (options.recursive) io.writeStdout(e.encode("\n"));
} }
if (options.recursive) { if (options.recursive) {
@@ -278,18 +277,18 @@ async function main(io: CommandIO, state: ShellState, args: string[]): Promise<C
} }
} }
function longMode(io: CommandIO, state: ShellState, nodes: TreeNode[]): void { function longMode(io: CommandIO, state: ShellState, children: TreeNode[], current: TreeNode): void {
const e = new TextEncoder(); const e = new TextEncoder();
const buff: Uint8Array[] = []; const buff: Uint8Array[] = [];
const nodes: TreeNode[] = [...children];
if (options.all) { if (options.all) {
const cwdNode = state.filesystem.getNode(nodes[0]!.parent)!; const parentNode = state.filesystem.getNode(current.parent)!;
const parentNode = state.filesystem.getNode(cwdNode.parent)!;
const parent: TreeNode = { ...parentNode, name: ".." }; const parent: TreeNode = { ...parentNode, name: ".." };
nodes.unshift(parent); nodes.unshift(parent);
const cwd: TreeNode = { ...cwdNode, name: "." }; const cwd: TreeNode = { ...current, name: "." };
nodes.unshift(cwd); nodes.unshift(cwd);
} }
+6 -6
View File
@@ -53,12 +53,12 @@ Shell.init(state);
//console.log(sortTreeNodes(Shell.Instance?.State!, dnTraverseTree(Shell.Instance?.State.filesystem!, 0))); //console.log(sortTreeNodes(Shell.Instance?.State!, dnTraverseTree(Shell.Instance?.State.filesystem!, 0)));
Shell.Instance().on("result", payload => { Shell.Instance().on("result", payload => {
const decoded = new TextDecoder().decode(payload.result.stdout.toArray()); //const decoded = new TextDecoder().decode(payload.result.stdout.toArray());
if (payload.result.type === "error") { if (payload.result.type === "error") {
console.log(payload.result.error.message + "\n"); console.log(payload.result.error.message + "\n");
} }
process.stdout.write(decoded + "\n"); //process.stdout.write(decoded + "\n");
process.stdout.write(resolveInodeToHome(payload.state, getCurrentSession(payload.state).cwd) + "\n> "); process.stdout.write("\n" + resolveInodeToHome(payload.state, getCurrentSession(payload.state).cwd) + "\n> ");
}); });
/* /*
@@ -67,10 +67,10 @@ Shell.Instance().on("result", payload => {
Need to use this only if a continuous process is running Need to use this only if a continuous process is running
*/ */
/* Shell.Instance?.on("stdout", payload => { Shell.Instance().on("stdout", payload => {
const decoded = new TextDecoder().decode(payload.data); const decoded = new TextDecoder().decode(payload.data);
process.stdout.write(decoded + "\n"); process.stdout.write(decoded);
}); */ });
console.clear(); console.clear();
process.stdout.write(resolveInodeToHome(state, getCurrentSession(state).cwd) + "\n> "); process.stdout.write(resolveInodeToHome(state, getCurrentSession(state).cwd) + "\n> ");
+1 -1
View File
@@ -31,7 +31,7 @@ export class Process {
this.CommandDescriptor = descriptor; this.CommandDescriptor = descriptor;
this.Args = args; this.Args = args;
// Check if positive later and throw an error if so // Check if positive later and throw an error if so
this._MaxChunkByteSize = 8096; this._MaxChunkByteSize = 1024;
this._EventEmitter = new EventEmitter<ShellEventMap>(); this._EventEmitter = new EventEmitter<ShellEventMap>();
} }