MCPcopy Index your code
hub / github.com/codeaashu/claude-code / applyVarToScope

Function applyVarToScope

src/utils/bash/ast.ts:2017–2027  ·  view source on GitHub ↗

* Apply a variable assignment to the scope, handling `+=` append semantics. * SECURITY: If EITHER side (existing value or appended value) contains a * placeholder, the result is non-literal — store VAR_PLACEHOLDER so later * $VAR correctly rejects as bare arg. * `VAR=/etc && VAR+=$(cmd)` must no

(
  varScope: Map<string, string>,
  ev: { name: string; value: string; isAppend: boolean },
)

Source from the content-addressed store, hash-verified

2015 * `VAR=/etc && VAR+=$(cmd)` must not leave VAR looking static.
2016 */
2017function applyVarToScope(
2018 varScope: Map<string, string>,
2019 ev: { name: string; value: string; isAppend: boolean },
2020): void {
2021 const existing = varScope.get(ev.name) ?? ''
2022 const combined = ev.isAppend ? existing + ev.value : ev.value
2023 varScope.set(
2024 ev.name,
2025 containsAnyPlaceholder(combined) ? VAR_PLACEHOLDER : combined,
2026 )
2027}
2028
2029function stripRawString(text: string): string {
2030 return text.slice(1, -1)

Callers 1

collectCommandsFunction · 0.85

Calls 3

containsAnyPlaceholderFunction · 0.85
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected