MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / tryParseShellCommand

Function tryParseShellCommand

source code/utils/bash/shellQuote.ts:26–47  ·  view source on GitHub ↗
(
  cmd: string,
  env?:
    | Record<string, string | undefined>
    | ((key: string) => string | undefined),
)

Source from the content-addressed store, hash-verified

24 | { success: false; error: string }
25
26export 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
49export function tryQuoteShellArgs(args: unknown[]): ShellQuoteResult {
50 try {

Callers 15

isLinePrintingCommandFunction · 0.85
isSubstitutionCommandFunction · 0.85
hasFileArgsFunction · 0.85
extractSedExpressionsFunction · 0.85
bashToolHasPermissionFunction · 0.85
isNormalizedGitCommandFunction · 0.85
isNormalizedCdCommandFunction · 0.85
checkReadOnlyConstraintsFunction · 0.85
parseCommandArgumentsFunction · 0.85

Calls 1

logErrorFunction · 0.50

Tested by

no test coverage detected