- cat added

- touch beginnings
- path resolver now returns a -1 on error
- added a command template file for easier copy-pasting
This commit is contained in:
2026-09-01 05:47:23 +02:00
parent 8e054a220d
commit 2e9227f6d8
7 changed files with 169 additions and 25 deletions
+2 -11
View File
@@ -39,8 +39,8 @@ async function main(
} else if (args[0] === "-") {
inode = session.pwd;
} else {
const result = safeResolvePath(state, args[0]);
if (result.type === "error") {
inode = resolvePath(state, args[0]);
if (inode === -1) {
return {
state,
result: createErrorResult(
@@ -51,7 +51,6 @@ async function main(
),
} satisfies CommandOutput<PathResolutionError>;
}
inode = result.inode;
}
if (state.filesystem.isFile(inode)) {
@@ -74,14 +73,6 @@ async function main(
state: returnState,
result: createSuccessResult(COMMAND_NAME),
};
function safeResolvePath(state: ShellState, path: string): { type: "success"; inode: number } | { type: "error" } {
try {
return { type: "success", inode: resolvePath(state, path) };
} catch {
return { type: "error" };
}
}
}
export const descriptor: CommandDescriptor = {