bigass changes

- ls beginnings,
- added groups to shellstate
- made buffers optional in result factory functions,
- made an enum signal map,
- fixed a minor bug in path resolver that didnt output the '/' if     the inode was at root (inode 0) from the moment it was called

- added code that attaches the shell to the built-in IDE terminal

--

tests need fixing, new code needs testing
This commit is contained in:
2026-08-24 10:30:04 +02:00
parent 48aac3c883
commit dad18cd4cc
14 changed files with 380 additions and 82 deletions
+10 -1
View File
@@ -1,22 +1,25 @@
import type { FileSystem } from "./filesystem/filesystem";
import { addHistoryEntry } from "./history_state";
import type { UserInfo } from "./session_manager";
import type { GroupInfo, UserInfo } from "./session_manager";
import { createInitialSessionState, getCurrentSession, type SessionState } from "./session_manager";
export interface ShellState {
readonly filesystem: FileSystem;
readonly users: ReadonlyMap<number, UserInfo>;
readonly groups: ReadonlyMap<number, GroupInfo>;
readonly sessionStack: ReadonlyArray<SessionState>;
}
export function createInitialShellState(
filesystem: FileSystem,
users: ReadonlyMap<number, UserInfo>,
groups: ReadonlyMap<number, GroupInfo>,
user: UserInfo,
): ShellState {
return Object.freeze({
filesystem,
users,
groups,
sessionStack: Object.freeze([createInitialSessionState(user)]),
});
}
@@ -24,11 +27,13 @@ export function createInitialShellState(
export function createShellState(
filesystem: FileSystem,
users: ReadonlyMap<number, UserInfo>,
groups: ReadonlyMap<number, GroupInfo>,
sessionStack: ReadonlyArray<SessionState>,
): ShellState {
return Object.freeze({
filesystem,
users,
groups,
sessionStack: Object.freeze(sessionStack),
});
}
@@ -52,6 +57,7 @@ export function withCwd(state: ShellState, inode: number): ShellState {
return Object.freeze({
filesystem: state.filesystem,
users: state.users,
groups: state.groups,
sessionStack: Object.freeze(sessionStack),
} satisfies ShellState);
}
@@ -75,6 +81,7 @@ export function withHistory(state: ShellState, input: string): ShellState {
return Object.freeze({
filesystem: state.filesystem,
users: state.users,
groups: state.groups,
sessionStack: Object.freeze(sessionStack),
} satisfies ShellState);
}
@@ -101,6 +108,7 @@ export function withEnv(state: ShellState, key: string, value: string): ShellSta
return Object.freeze({
filesystem: state.filesystem,
users: state.users,
groups: state.groups,
sessionStack: Object.freeze(sessionStack),
} satisfies ShellState);
}
@@ -124,6 +132,7 @@ export function withExitCode(state: ShellState, exitCode: number): ShellState {
return Object.freeze({
filesystem: state.filesystem,
users: state.users,
groups: state.groups,
sessionStack: Object.freeze(sessionStack),
} satisfies ShellState);
}