Skip to content

fix(install.ps1): use string concatenation instead of interpolation w… - #201

Merged
Nan0pk merged 2 commits into
mainfrom
fix/install-ps1-syntax-error
Jun 30, 2026
Merged

fix(install.ps1): use string concatenation instead of interpolation w…#201
Nan0pk merged 2 commits into
mainfrom
fix/install-ps1-syntax-error

Conversation

@Nan0pk

@Nan0pk Nan0pk commented Jun 30, 2026

Copy link
Copy Markdown
Owner

…/ parens

PS 5.1 still failing on line 381 even after the previous fix:

At C:\Users\TTT\install.ps1:381 char:51

  • Write-Host "`r $Pct% ($WrittenMB MB / $TotalMB MB) @ ...
  •                                        ~~
    

Unexpected token 'MB' in expression or statement.

Root cause: PowerShell 5.1's tokenizer treats the opening paren inside a double-quoted string followed by a variable as a potential subexpression start, and when the contents don't form a valid subexpression, the parser falls over. The pattern ($Varname Text) is the specific trigger.

The previous fix used native string interpolation with the suspect pattern still embedded:
Write-Host "`r $Pct% ($WrittenMB MB / $TotalMB MB) @ $Rate MB/s" -NoNewline

This commit replaces it with explicit string concatenation — no parens inside the string at all:

$ProgressLine = "`r " + $Pct + "% " + $WrittenMB + " MB / " + $TotalMB + " MB @ " + $Rate + " MB/s"
Write-Host $ProgressLine -NoNewline

Verified:

  • PowerShell 7 parser: PARSE OK (0 errors).
  • Static scan for suspect '(' patterns in string literals: 0 found.
  • install.ps1 -Help still runs cleanly.

Lesson learned: stop hand-writing PowerShell string interpolation that contains parentheses. Use concatenation, or pre-compute variables and reference them with simple $Varname interpolation (no parens).

What Does This Change?

A clear description of what this PR changes and why.

Motivation

Why is this change needed? Link to the issue it resolves (e.g., Closes #123)
or explain the problem it solves.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Refactor (no functional change)
  • Documentation update
  • CI / build system change
  • Kernel config change
  • Policy / defaults change

Testing

  • cargo test --workspace passes
  • cargo clippy --workspace --all-targets -- -D warnings passes
  • cargo fmt --all -- --check passes
  • pwsh ./tools/validate-repo.ps1 passes
  • python3 tools/validate-evidence.py passes (Dragnet gate)
  • New or updated tests added for this change

Evidence (Dragnet)

  • If this PR sets any milestone criterion verified = true, it commits the
    acceptance transcript and python3 tools/dragnet.py --observe is GREEN
    with zero pending ledger rows for that milestone. (See docs/dragnet-protocol.md.)

Documentation

Documentation updates are required for changes to behavior, defaults,
policy, boot/update flow, kernel fragments, recipes, or service behavior.

  • No documentation update needed (explain why below)
  • docs/IMPLEMENTATION_STATUS.md updated
  • Relevant docs updated (list which ones):

  • ADR added or amended (if this changes architectural direction)

If no doc update is needed, explain why:


Checklist

  • I have read CONTRIBUTING.md
  • My changes follow the project's design rules (modern defaults,
    one adaptive policy owner, explainable behavior)
  • No legacy defaults were introduced without justification
  • No guardrails were weakened
  • If this changes privileged actions, SECURITY.md and relevant
    ADRs are updated

…/ parens

PS 5.1 still failing on line 381 even after the previous fix:

  At C:\Users\TTT\install.ps1:381 char:51
  +  Write-Host "`r  $Pct% ($WrittenMB MB / $TotalMB MB) @ ...
  +                                            ~~
  Unexpected token 'MB' in expression or statement.

Root cause: PowerShell 5.1's tokenizer treats the opening paren inside
a double-quoted string followed by a variable as a potential subexpression
start, and when the contents don't form a valid subexpression, the parser
falls over. The pattern ($Varname Text) is the specific trigger.

The previous fix used native string interpolation with the suspect
pattern still embedded:
  Write-Host "`r  $Pct% ($WrittenMB MB / $TotalMB MB) @ $Rate MB/s" -NoNewline

This commit replaces it with explicit string concatenation — no parens
inside the string at all:

  $ProgressLine = "`r  " + $Pct + "% " + $WrittenMB + " MB / " + $TotalMB + " MB @ " + $Rate + " MB/s"
  Write-Host $ProgressLine -NoNewline

Verified:
  - PowerShell 7 parser: PARSE OK (0 errors).
  - Static scan for suspect '(<dollar>' patterns in string literals: 0 found.
  - install.ps1 -Help still runs cleanly.

Lesson learned: stop hand-writing PowerShell string interpolation that
contains parentheses. Use concatenation, or pre-compute variables and
reference them with simple $Varname interpolation (no parens).
@Nan0pk
Nan0pk enabled auto-merge June 30, 2026 12:33
@Nan0pk
Nan0pk merged commit 461c081 into main Jun 30, 2026
24 checks passed
@Nan0pk
Nan0pk deleted the fix/install-ps1-syntax-error branch July 1, 2026 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant