(
cmd: string,
env?:
| Record<string, string | undefined>
| ((key: string) => string | undefined),
)
| 24 | | { success: false; error: string } |
| 25 | |
| 26 | export function tryParseShellCommand( |
| 27 | cmd: string, |
| 28 | env?: |
| 29 | | Record<string, string | undefined> |
| 30 | | ((key: string) => string | undefined), |
| 31 | ): ShellParseResult { |
| 32 | try { |
| 33 | const tokens = |
| 34 | typeof env === 'function' |
| 35 | ? shellQuoteParse(cmd, env) |
| 36 | : shellQuoteParse(cmd, env) |
| 37 | return { success: true, tokens } |
| 38 | } catch (error) { |
| 39 | if (error instanceof Error) { |
| 40 | logError(error) |
| 41 | } |
| 42 | return { |
| 43 | success: false, |
| 44 | error: error instanceof Error ? error.message : 'Unknown parse error', |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | export function tryQuoteShellArgs(args: unknown[]): ShellQuoteResult { |
| 50 | try { |
no test coverage detected