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

Function tryQuoteShellArgs

source code/utils/bash/shellQuote.ts:49–97  ·  view source on GitHub ↗
(args: unknown[])

Source from the content-addressed store, hash-verified

47}
48
49export function tryQuoteShellArgs(args: unknown[]): ShellQuoteResult {
50 try {
51 const validated: string[] = args.map((arg, index) => {
52 if (arg === null || arg === undefined) {
53 return String(arg)
54 }
55
56 const type = typeof arg
57
58 if (type === 'string') {
59 return arg as string
60 }
61 if (type === 'number' || type === 'boolean') {
62 return String(arg)
63 }
64
65 if (type === 'object') {
66 throw new Error(
67 `Cannot quote argument at index ${index}: object values are not supported`,
68 )
69 }
70 if (type === 'symbol') {
71 throw new Error(
72 `Cannot quote argument at index ${index}: symbol values are not supported`,
73 )
74 }
75 if (type === 'function') {
76 throw new Error(
77 `Cannot quote argument at index ${index}: function values are not supported`,
78 )
79 }
80
81 throw new Error(
82 `Cannot quote argument at index ${index}: unsupported type ${type}`,
83 )
84 })
85
86 const quoted = shellQuoteQuote(validated)
87 return { success: true, quoted }
88 } catch (error) {
89 if (error instanceof Error) {
90 logError(error)
91 }
92 return {
93 success: false,
94 error: error instanceof Error ? error.message : 'Unknown quote error',
95 }
96 }
97}
98
99/**
100 * Checks if parsed tokens contain malformed entries that suggest shell-quote

Callers 1

quoteFunction · 0.85

Calls 1

logErrorFunction · 0.50

Tested by

no test coverage detected