import type { ExecAction } from '../../commands/builtin/types.ts';
import type { Identity } from '../../commands/builtin/utils/identity.ts';
import { type ByteSource, type PathRecord } from '../../io/types.ts';
import type { FindExpr } from '../../rs/find.ts';
import type { DispatchFn } from '../../runtime/types.ts';
import { type PathSpec } from '../../types.ts';
import type { StatPath } from '../../view/types.ts';
import type { ExecuteFn } from '../expand/types.ts';
import type { Files } from '../files.ts';
import type { MountRegistry } from '../mount/registry.ts';
import type { SessionState } from '../session/session.ts';
/**
 * The shell line one `-exec` run becomes. GNU execs the words directly, so
 * every match must reach the command as exactly one argv word: the line is
 * built with `shellJoin`, and a plain join would be re-parsed by the shell.
 * A per-match run substitutes every `{}` inside every word (`x{}y` is
 * `xd/a.txty`); a batched run replaces its one bare `{}` with the matches,
 * one word each.
 */
/**
 * The argv one `-exec` run becomes, matches substituted: a per-match run
 * substitutes every `{}` inside every word (`x{}y` is `xd/a.txty`), a
 * batched run replaces its one bare `{}` with the matches, one word
 * each. The head is substituted like any other word, which is what lets
 * `-exec {} \;` run each match itself.
 */
export declare function execWords(action: ExecAction, paths: readonly string[]): string[];
/**
 * Whether `execvp` would fail to find a head word (`find -exec`, `exec`),
 * and whether a shell function shadows the program it would find. A head
 * carrying a slash is a file the loader runs, which no builtin, function or
 * CLI can claim, so it is statted where the line would read it; any other
 * head is looked up by name across the layers dispatch consults, in
 * `session`'s shell. Outside a workspace there is no stat and the loader
 * answers for itself.
 */
export declare function programHead(head: string, session: SessionState | null, registry: MountRegistry, cwd: string, statPath: StatPath | null): Promise<[boolean, boolean]>;
/**
 * GNU's `-depth` order over sorted siblings: a directory's contents, each
 * sorted, then the directory. The final component is flagged so a path
 * sorts after its descendants, whose entry at that depth carries the same
 * name unflagged. A start point spelled with a trailing slash prints as
 * `d/` while its descendants print as `d/a`, so the slash is dropped
 * before splitting: kept, it would leave an empty final component that
 * sorts the directory ahead of everything under it, which is the one
 * order `-delete` cannot remove a tree in.
 */
export declare function compareDepthFirst(a: string, b: string): number;
/**
 * Apply find's actions (-exec / -delete / -print0 / -ls / -printf) to its
 * rows.
 *
 * Per-VFS find handlers only emit matched paths. This dispatcher
 * layer re-reads the actions off the expression and applies them per
 * match, in the order they were written, the way GNU's implicit `-a`
 * chain runs: each per-match `-exec` runs in turn and the first that
 * fails ends the chain for that match, so a later `-print` (or `-ls`,
 * `-print0`, `-printf`, `-delete`) sees only the matches every earlier
 * `-exec` accepted (`-exec grep -q x {} ";" -print`), and `-exec echo {}
 * ";" -print -exec echo again {} ";"` alternates the three per match. A
 * batched `-exec ... {} +` collects the match at its position and runs
 * once after the walk; a failing batch is find's exit 1, as is a row it
 * could not delete, list or stat for a `-printf`, and either ends that
 * row's chain; a failing per-match run is not, and neither is a command
 * that cannot be found, which GNU reports per match and carries on from
 * with exit 0. An action other than `-print` suppresses
 * the implicit print. `-delete` runs at its position, so a later `-exec`
 * sees the row gone, and a row it cannot delete ends the chain with GNU's
 * line and find's exit 1. It also turns on `-depth`, which orders every
 * directory after its contents, the only order a tree can be removed in;
 * `-depth` alone reorders the implicit print the same way, and both
 * order one start point's walk at a time: GNU walks each start point to
 * completion before the next, so `find b a -depth` prints `b/x b a/y a`
 * and `find d d/sub -depth` finishes `d` before it begins `d/sub` again,
 * which is why each row names the start point it was found under;
 * `-printf`'s %P and %d measure a row from that start point. Returns the rows to print, the stderr to append, and the
 * exit status the actions impose (0 when they impose none, even with
 * stderr).
 */
export declare function applyFindActions(stdout: ByteSource | null, records: readonly PathRecord[] | null, expr: FindExpr, registry: MountRegistry, cwd: string, options?: {
    executeFn?: ExecuteFn;
    session?: SessionState;
    signal?: AbortSignal;
    vfs?: Files | null;
    statPath?: StatPath | null;
    dispatch?: DispatchFn | null;
    identity?: Identity | null;
    stdin?: ByteSource | null;
    /** The start operands, whose rows GNU statted when it opened the
     * walk; empty means the working directory. */
    readonly starts?: readonly PathSpec[];
}): Promise<[ByteSource | null, Uint8Array, number]>;
//# sourceMappingURL=find_action_dispatch.d.ts.map