- 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:
+2
-11
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user