UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

41 lines • 2.41 kB
import type { RedirectResult } from '../../../../context/session_context.ts'; import type { ByteSource } from '../../../../io/types.ts'; import type { DispatchFn } from '../../../../runtime/types.ts'; import { CallStack } from '../../../../shell/call_stack.ts'; import { type JobConsole } from '../../../../shell/console/index.ts'; import type { JobTable } from '../../../../shell/job_table/index.ts'; import { EvaluationContext } from '../../../evaluation.ts'; import type { BuiltinCall, ExecuteStringFn } from '../types.ts'; import type { BashArgs } from './types.ts'; /** * Read Bash startup options, then select a program and its argv. * * GNU Bash 5.2 reads long options (one or two dashes) before short ones. * Help/version return after that pass: unknown long options still fail, * while help outranks version and unsupported modes. A long option after * a short one is refused as `--`. Unsupported short options name the * whole character here, rather than its first byte as GNU does. * * Options after a script file or `-c`'s program are positional; `-` and * `--` end option parsing. `-c` takes the next word, never the rest of its * cluster: `-cx 'echo hi'` traces and runs `echo hi`. */ export declare function parseBashArgs(args: string[]): BashArgs; /** * Run a nested shell: inline text from `-c`, or a script file. * * `name` is the head word (`bash` or `sh`). bash reports itself by * `argv[0]`, so the diagnostics follow the spelling the caller used. * * A nested shell is a program of its own, so it runs on a new shell started * from the session's environment (`SessionState.newShell`) and leaves the * caller's state alone: `bash -c 'cd /x'` leaves the caller where it was, * and `x=1; bash -c 'echo $x'` prints an empty line, as in bash, where the * nested shell is a separate process. `handleSource` is the opposite case * and deliberately runs on the caller's session, because a sourced file is * the caller. */ export declare function handleBash(dispatch: DispatchFn, executeFn: ExecuteStringFn, args: string[], context: EvaluationContext, stdin?: ByteSource | null, name?: string, sink?: JobConsole, jobTable?: JobTable, callStack?: CallStack | null): Promise<RedirectResult>; /** The `bash` / `sh` arm; the head word names the nested shell. */ export declare function bashBuiltin(call: BuiltinCall): Promise<RedirectResult>; //# sourceMappingURL=bash.d.ts.map