@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
42 lines • 1.46 kB
TypeScript
/**
* Shell-quote an argument for safe interpolation into a shell command string.
* Safe characters (alphanumeric, `.`, `_`, `-`, `/`, `=`, `:`, `@`) pass through.
* Everything else is wrapped in single quotes with embedded quotes escaped.
*/
export declare function shellQuote(arg: string): string;
/**
* Result of splitting a shell command string.
*/
export interface ShellSplitResult {
/** Command parts between operators */
parts: string[];
/** Operators that were found (&&, ||, ;) */
operators: string[];
}
/**
* Split a shell command string on operators (&&, ||, ;) while respecting quotes.
*
* This is a quote-aware splitter that won't split inside single or double quoted strings.
* Handles escaped quotes within quoted strings.
*
* @example
* ```typescript
* splitShellCommand('echo "hello && world" && ls')
* // => { parts: ['echo "hello && world"', 'ls'], operators: ['&&'] }
*
* splitShellCommand("bash -c 'cd /tmp && pwd' || echo fail")
* // => { parts: ["bash -c 'cd /tmp && pwd'", 'echo fail'], operators: ['||'] }
* ```
*/
export declare function splitShellCommand(command: string): ShellSplitResult;
/**
* Reassemble command parts with their operators.
*
* @example
* ```typescript
* reassembleShellCommand(['echo hello', 'ls'], ['&&'])
* // => 'echo hello && ls'
* ```
*/
export declare function reassembleShellCommand(parts: string[], operators: string[]): string;
//# sourceMappingURL=utils.d.ts.map