@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
33 lines • 2.01 kB
TypeScript
import type { RedirectResult } from '../../../../context/session_context.ts';
import type { SessionView } from '../../../../view/types.ts';
import type { SessionState } from '../../../session/session.ts';
import type { BuiltinCall } from '../types.ts';
/**
* Print formatted output, honoring GNU printf's format-reuse rules.
*
* Supports `%s %c %b %q`, the integer conversions `%d %i %o %u %x %X`,
* the float conversions `%f %F %e %E %g %G %a %A`, and `%%`, with
* `- + 0 # (space)` flags, numeric or `*` width/precision, and backslash
* escapes (including `\u`/`\U`) interpreted once in the same scan. When
* arguments remain after one pass the format is reused until they are
* exhausted; a missing argument renders as the empty string / `0`.
* Integers saturate at 64-bit limits; negative unsigned values wrap. `%a`
* formats at IEEE double precision. The shared Rust stream owns conversions.
*
* With `-v NAME` the formatted text is stored in the shell variable
* `NAME` (or the array element `NAME[idx]`) instead of written to
* stdout, matching bash's builtin. An unusable `NAME` is rejected before
* the format runs (status 2); a readonly name or an out-of-range subscript
* still reports the format's own errors first, then fails with status 1
* and leaves the variable untouched. bash stores the bytes the format
* produced, so a `\x` run that is valid UTF-8 is stored as its characters,
* and up to the first NUL, which no variable holds (`printf -v n '1\0002'`
* stores 1). `-v` is the builtin's alone: run as a program (`find -exec
* printf`, which execvp answers with coreutils printf) the word is the
* format, and a format that takes no argument warns about the ones it
* drops.
*/
export declare function handlePrintf(args: string[], session: SessionState, view?: SessionView, signal?: AbortSignal): Promise<RedirectResult>;
/** The `printf` arm. */
export declare function printfBuiltin(call: BuiltinCall): Promise<RedirectResult>;
//# sourceMappingURL=printf.d.ts.map